@Deprecated
public class DynamoDBMapper
extends java.lang.Object
To use, annotate domain classes with the annotations found in the com.amazonaws.services.dynamodb.datamodeling package. A minimal example:
@DynamoDBTable(tableName = "TestTable")
public class TestClass {
private Long key;
private double rangeKey;
private Long version;
private Set<Integer> integerSetAttribute;
@DynamoDBHashKey
public Long getKey() {
return key;
}
public void setKey(Long key) {
this.key = key;
}
@DynamoDBRangeKey
public double getRangeKey() {
return rangeKey;
}
public void setRangeKey(double rangeKey) {
this.rangeKey = rangeKey;
}
@DynamoDBAttribute(attributeName = "integerSetAttribute")
public Set<Integer> getIntegerAttribute() {
return integerSetAttribute;
}
public void setIntegerAttribute(Set<Integer> integerAttribute) {
this.integerSetAttribute = integerAttribute;
}
@DynamoDBVersionAttribute
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
}
Save instances of annotated classes to DynamoDB, retrieve them, and delete
them using the DynamoDBMapper class, as in the following example.
DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBClient); Long hashKey = 105L; double rangeKey = 1.0d; TestClass obj = mapper.load(TestClass.class, hashKey, rangeKey); obj.getIntegerAttribute().add(42); mapper.save(obj); mapper.delete(obj);
When using the save, load, and delete methods, DynamoDBMapper will
throw DynamoDBMappingExceptions to indicate that domain classes are
incorrectly annotated or otherwise incompatible with this class. Service
exceptions will always be propagated as AmazonClientException, and
DynamoDB-specific subclasses such as ConditionalCheckFailedException
will be used when possible.
This class is thread-safe and can be shared between threads. It's also very lightweight, so it doesn't need to be.
| コンストラクタと説明 |
|---|
DynamoDBMapper(AmazonDynamoDB dynamoDB)
非推奨です。
Constructs a new mapper with the service object given, using the default
configuration.
|
DynamoDBMapper(AmazonDynamoDB dynamoDB,
DynamoDBMapperConfig config)
非推奨です。
Constructs a new mapper with the service object and configuration given.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
void |
batchDelete(java.util.List<? extends java.lang.Object> objectsToDelete)
非推奨です。
Deletes the objects given using one or more calls to the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API. |
void |
batchDelete(java.lang.Object... objectsToDelete)
非推奨です。
Deletes the objects given using one or more calls to the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API. |
java.util.Map<java.lang.String,java.util.List<java.lang.Object>> |
batchLoad(java.util.Map<java.lang.Class<?>,java.util.List<KeyPair>> itemsToGet)
非推奨です。
Retrieves the attributes for multiple items from multiple tables using
their primary keys.
|
java.util.Map<java.lang.String,java.util.List<java.lang.Object>> |
batchLoad(java.util.Map<java.lang.Class<?>,java.util.List<KeyPair>> itemsToGet,
DynamoDBMapperConfig config)
非推奨です。
Retrieves the attributes for multiple items from multiple tables using
their primary keys.
|
void |
batchSave(java.util.List<? extends java.lang.Object> objectsToSave)
非推奨です。
Saves the objects given using one or more calls to the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API. |
void |
batchSave(java.lang.Object... objectsToSave)
非推奨です。
Saves the objects given using one or more calls to the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API. |
void |
batchWrite(java.util.List<? extends java.lang.Object> objectsToWrite,
java.util.List<? extends java.lang.Object> objectsToDelete)
非推奨です。
Saves and deletes the objects given using one or more calls to the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API. |
void |
batchWrite(java.util.List<? extends java.lang.Object> objectsToWrite,
java.util.List<? extends java.lang.Object> objectsToDelete,
DynamoDBMapperConfig config)
非推奨です。
Saves and deletes the objects given using one or more calls to the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API. |
int |
count(java.lang.Class<?> clazz,
DynamoDBQueryExpression queryExpression)
非推奨です。
Evaluates the specified query expression and returns the count of matching
items, without returning any of the actual item data, using the default configuration.
|
int |
count(java.lang.Class<?> clazz,
DynamoDBQueryExpression queryExpression,
DynamoDBMapperConfig config)
非推奨です。
Evaluates the specified query expression and returns the count of
matching items, without returning any of the actual item data.
|
int |
count(java.lang.Class<?> clazz,
DynamoDBScanExpression scanExpression)
非推奨です。
Evaluates the specified scan expression and returns the count of matching
items, without returning any of the actual item data, using the default configuration.
|
int |
count(java.lang.Class<?> clazz,
DynamoDBScanExpression scanExpression,
DynamoDBMapperConfig config)
非推奨です。
Evaluates the specified scan expression and returns the count of matching
items, without returning any of the actual item data.
|
void |
delete(java.lang.Object object)
非推奨です。
Deletes the given object from its DynamoDB table.
|
void |
delete(java.lang.Object object,
DynamoDBMapperConfig config)
非推奨です。
Deletes the given object from its DynamoDB table.
|
<T> T |
load(java.lang.Class<T> clazz,
java.lang.Object hashKey)
非推奨です。
Loads an object with the hash key given, using the default configuration.
|
<T> T |
load(java.lang.Class<T> clazz,
java.lang.Object hashKey,
DynamoDBMapperConfig config)
非推奨です。
Loads an object with the hash key given and a configuration override.
|
<T> T |
load(java.lang.Class<T> clazz,
java.lang.Object hashKey,
java.lang.Object rangeKey)
非推奨です。
Loads an object with a hash and range key, using the default
configuration.
|
<T> T |
load(java.lang.Class<T> clazz,
java.lang.Object hashKey,
java.lang.Object rangeKey,
DynamoDBMapperConfig config)
非推奨です。
Returns an object with the given hash key, or null if no such object
exists.
|
<T> T |
marshallIntoObject(java.lang.Class<T> clazz,
java.util.Map<java.lang.String,AttributeValue> itemAttributes)
非推奨です。
Creates and fills in the attributes on an instance of the class given
with the attributes given.
|
<T> java.util.List<T> |
marshallIntoObjects(java.lang.Class<T> clazz,
java.util.List<java.util.Map<java.lang.String,AttributeValue>> itemAttributes)
非推奨です。
Marshalls the list of item attributes into objects of type clazz
|
<T> PaginatedQueryList<T> |
query(java.lang.Class<T> clazz,
DynamoDBQueryExpression queryExpression)
非推奨です。
Queries an Amazon DynamoDB table and returns the matching results as an
unmodifiable list of instantiated objects, using the default
configuration.
|
<T> PaginatedQueryList<T> |
query(java.lang.Class<T> clazz,
DynamoDBQueryExpression queryExpression,
DynamoDBMapperConfig config)
非推奨です。
Queries an Amazon DynamoDB table and returns the matching results as an
unmodifiable list of instantiated objects.
|
<T> QueryResultPage<T> |
queryPage(java.lang.Class<T> clazz,
DynamoDBQueryExpression queryExpression)
非推奨です。
Queries an Amazon DynamoDB table and returns a single page of matching
results.
|
<T> QueryResultPage<T> |
queryPage(java.lang.Class<T> clazz,
DynamoDBQueryExpression queryExpression,
DynamoDBMapperConfig config)
非推奨です。
Queries an Amazon DynamoDB table and returns a single page of matching
results.
|
<T> void |
save(T object)
非推奨です。
Saves the object given into DynamoDB, using the default configuration.
|
<T> void |
save(T object,
DynamoDBMapperConfig config)
非推奨です。
Saves an item in DynamoDB.
|
<T> PaginatedScanList<T> |
scan(java.lang.Class<T> clazz,
DynamoDBScanExpression scanExpression)
非推奨です。
Scans through an Amazon DynamoDB table and returns the matching results as
an unmodifiable list of instantiated objects, using the default configuration.
|
<T> PaginatedScanList<T> |
scan(java.lang.Class<T> clazz,
DynamoDBScanExpression scanExpression,
DynamoDBMapperConfig config)
非推奨です。
Scans through an Amazon DynamoDB table and returns the matching results as
an unmodifiable list of instantiated objects.
|
<T> ScanResultPage<T> |
scanPage(java.lang.Class<T> clazz,
DynamoDBScanExpression scanExpression)
非推奨です。
Scans through an Amazon DynamoDB table and returns a single page of matching
results.
|
<T> ScanResultPage<T> |
scanPage(java.lang.Class<T> clazz,
DynamoDBScanExpression scanExpression,
DynamoDBMapperConfig config)
非推奨です。
Scans through an Amazon DynamoDB table and returns a single page of matching
results.
|
protected java.util.Map<java.lang.String,AttributeValue> |
transformAttributes(java.lang.Class<?> clazz,
java.util.Map<java.lang.String,AttributeValue> attributeValues)
非推奨です。
By default, just calls
transformAttributes(String, String, Map). |
protected java.util.Map<java.lang.String,AttributeValue> |
transformAttributes(java.lang.String hashKey,
java.lang.String rangeKey,
java.util.Map<java.lang.String,AttributeValue> attributeValues)
非推奨です。
Transform attribute values prior to storing in DynamoDB.
|
protected java.util.Map<java.lang.String,AttributeValue> |
untransformAttributes(java.lang.Class<?> clazz,
java.util.Map<java.lang.String,AttributeValue> attributeValues)
非推奨です。
By default, just calls
untransformAttributes(String, String, Map). |
protected java.util.Map<java.lang.String,AttributeValue> |
untransformAttributes(java.lang.String hashKey,
java.lang.String rangeKey,
java.util.Map<java.lang.String,AttributeValue> attributeValues)
非推奨です。
Transforms the attribute values after loading from DynamoDb.
|
public DynamoDBMapper(AmazonDynamoDB dynamoDB)
dynamoDB - The service object to use for all service calls.DynamoDBMapperConfig.DEFAULTpublic DynamoDBMapper(AmazonDynamoDB dynamoDB, DynamoDBMapperConfig config)
dynamoDB - The service object to use for all service calls.config - The default configuration to use for all service calls. It can
be overridden on a per-operation basis.public <T> T load(java.lang.Class<T> clazz,
java.lang.Object hashKey,
DynamoDBMapperConfig config)
public <T> T load(java.lang.Class<T> clazz,
java.lang.Object hashKey)
public <T> T load(java.lang.Class<T> clazz,
java.lang.Object hashKey,
java.lang.Object rangeKey)
public <T> T load(java.lang.Class<T> clazz,
java.lang.Object hashKey,
java.lang.Object rangeKey,
DynamoDBMapperConfig config)
clazz - The class to load, corresponding to a DynamoDB table.hashKey - The key of the object.rangeKey - The range key of the object, or null for tables without a
range key.config - Configuration for the service call to retrieve the object from
DynamoDB. This configuration overrides the default given at
construction.public <T> T marshallIntoObject(java.lang.Class<T> clazz,
java.util.Map<java.lang.String,AttributeValue> itemAttributes)
This is accomplished by looking for getter methods annotated with an appropriate annotation, then looking for matching attribute names in the item attribute map.
clazz - The class to instantiate and hydrateitemAttributes - The set of item attributes, keyed by attribute name.public <T> java.util.List<T> marshallIntoObjects(java.lang.Class<T> clazz,
java.util.List<java.util.Map<java.lang.String,AttributeValue>> itemAttributes)
public <T> void save(T object)
public <T> void save(T object,
DynamoDBMapperConfig config)
DynamoDBMapperConfig.getSaveBehavior() value, to use either
AWSDynamoDB#putItem(PutItemRequest) or
AWSDynamoDB#updateItem(UpdateItemRequest). For updates, a null
value for an object property will remove it from that item in DynamoDB.
For puts, a null value will not be passed to the service. The effect is
therefore the same, except when the item in DynamoDB contains attributes
that aren't modeled by the domain object given.object - The object to save into DynamoDBconfig - The configuration to use, which overrides the default provided
at object construction.public void delete(java.lang.Object object)
public void delete(java.lang.Object object,
DynamoDBMapperConfig config)
config - Config override object. If DynamoDBMapperConfig.SaveBehavior.CLOBBER is
supplied, version fields will not be considered when deleting
the object.public void batchDelete(java.util.List<? extends java.lang.Object> objectsToDelete)
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API.public void batchDelete(java.lang.Object... objectsToDelete)
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API.public void batchSave(java.util.List<? extends java.lang.Object> objectsToSave)
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API.public void batchSave(java.lang.Object... objectsToSave)
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API.public void batchWrite(java.util.List<? extends java.lang.Object> objectsToWrite,
java.util.List<? extends java.lang.Object> objectsToDelete)
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API.public void batchWrite(java.util.List<? extends java.lang.Object> objectsToWrite,
java.util.List<? extends java.lang.Object> objectsToDelete,
DynamoDBMapperConfig config)
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest) API.objectsToWrite - A list of objects to save to DynamoDB. No version checks are
performed, as required by the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest)
API.objectsToDelete - A list of objects to delete from DynamoDB. No version checks
are performed, as required by the
AmazonDynamoDB.batchWriteItem(BatchWriteItemRequest)
API.config - Only DynamoDBMapperConfig.getTableNameOverride() is
considered; if specified, all objects in the two parameter
lists will be considered to belong to the given table
override.public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> batchLoad(java.util.Map<java.lang.Class<?>,java.util.List<KeyPair>> itemsToGet)
AmazonDynamoDB.batchGetItem(BatchGetItemRequest) API.DynamoDBMapper#batchLoad(Map, List, DynamoDBMapperConfig)public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> batchLoad(java.util.Map<java.lang.Class<?>,java.util.List<KeyPair>> itemsToGet, DynamoDBMapperConfig config)
AmazonDynamoDB.batchGetItem(BatchGetItemRequest) API.itemsToGet - Container for the necessary parameters to execute the
BatchGetItem service method on Amazon DynamoDB.
AmazonDynamoDB#batchWriteItem(BatchGetItemRequest)
API.config - Only DynamoDBMapperConfig.getTableNameOverride() is
considered; if specified, all objects in the two parameter
lists will be considered to belong to the given table
override.public <T> PaginatedScanList<T> scan(java.lang.Class<T> clazz, DynamoDBScanExpression scanExpression)
public <T> PaginatedScanList<T> scan(java.lang.Class<T> clazz, DynamoDBScanExpression scanExpression, DynamoDBMapperConfig config)
Callers should be aware that the returned list is unmodifiable, and any attempts to modify the list will result in an UnsupportedOperationException.
The unmodifiable list returned is lazily loaded when possible, so calls to DynamoDB will be made only as needed.
T - The type of the objects being returned.clazz - The class annotated with DynamoDB annotations describing how
to store the object data in Amazon DynamoDB.scanExpression - Details on how to run the scan, including any filters to apply
to limit results.config - The configuration to use for this scan, which overrides the
default provided at object construction.PaginatedScanListpublic <T> ScanResultPage<T> scanPage(java.lang.Class<T> clazz, DynamoDBScanExpression scanExpression, DynamoDBMapperConfig config)
T - The type of the objects being returned.clazz - The class annotated with DynamoDB annotations describing how
to store the object data in Amazon DynamoDB.scanExpression - Details on how to run the scan, including any filters to apply
to limit results.config - The configuration to use for this scan, which overrides the
default provided at object construction.public <T> ScanResultPage<T> scanPage(java.lang.Class<T> clazz, DynamoDBScanExpression scanExpression)
public <T> PaginatedQueryList<T> query(java.lang.Class<T> clazz, DynamoDBQueryExpression queryExpression)
public <T> PaginatedQueryList<T> query(java.lang.Class<T> clazz, DynamoDBQueryExpression queryExpression, DynamoDBMapperConfig config)
Callers should be aware that the returned list is unmodifiable, and any attempts to modify the list will result in an UnsupportedOperationException.
The unmodifiable list returned is lazily loaded when possible, so calls to DynamoDB will be made only as needed.
T - The type of the objects being returned.clazz - The class annotated with DynamoDB annotations describing how
to store the object data in Amazon DynamoDB.queryExpression - Details on how to run the query, including any conditions on
the key valuesconfig - The configuration to use for this query, which overrides the
default provided at object construction.PaginatedQueryListpublic <T> QueryResultPage<T> queryPage(java.lang.Class<T> clazz, DynamoDBQueryExpression queryExpression)
public <T> QueryResultPage<T> queryPage(java.lang.Class<T> clazz, DynamoDBQueryExpression queryExpression, DynamoDBMapperConfig config)
T - The type of the objects being returned.clazz - The class annotated with DynamoDB annotations describing how
to store the object data in AWS DynamoDB.queryExpression - Details on how to run the query, including any conditions on
the key valuesconfig - The configuration to use for this query, which overrides the
default provided at object construction.public int count(java.lang.Class<?> clazz,
DynamoDBScanExpression scanExpression)
public int count(java.lang.Class<?> clazz,
DynamoDBScanExpression scanExpression,
DynamoDBMapperConfig config)
This operation will scan your entire table, and can therefore be very expensive. Use with caution.
clazz - The class mapped to a DynamoDB table.scanExpression - The parameters for running the scan.config - The configuration to use for this scan, which overrides the
default provided at object construction.public int count(java.lang.Class<?> clazz,
DynamoDBQueryExpression queryExpression)
public int count(java.lang.Class<?> clazz,
DynamoDBQueryExpression queryExpression,
DynamoDBMapperConfig config)
clazz - The class mapped to a DynamoDB table.scanExpression - The parameters for running the scan.config - The mapper configuration to use for the query, which overrides
the default provided at object construction.protected java.util.Map<java.lang.String,AttributeValue> untransformAttributes(java.lang.Class<?> clazz, java.util.Map<java.lang.String,AttributeValue> attributeValues)
untransformAttributes(String, String, Map).clazz - attributeValues - protected java.util.Map<java.lang.String,AttributeValue> untransformAttributes(java.lang.String hashKey, java.lang.String rangeKey, java.util.Map<java.lang.String,AttributeValue> attributeValues)
untransformAttributes(Class, Map).
By default, returns the attributes unchanged. Currently, the
values associated with the hash key and range key must be left unchanged.hashKey - the attribute name of the hash keyrangeKey - the attribute name of the range key (or null if there is none)attributeValues - protected java.util.Map<java.lang.String,AttributeValue> transformAttributes(java.lang.Class<?> clazz, java.util.Map<java.lang.String,AttributeValue> attributeValues)
transformAttributes(String, String, Map).clazz - attributeValues - protected java.util.Map<java.lang.String,AttributeValue> transformAttributes(java.lang.String hashKey, java.lang.String rangeKey, java.util.Map<java.lang.String,AttributeValue> attributeValues)
transformAttributes(Class, Map).
By default, returns the attributes unchanged.hashKey - the attribute name of the hash keyrangeKey - the attribute name of the range key (or null if there is none)attributeValues -