public < T extends Object > T load ( Class < T > clazz , Object hashKey , Object rangeKey , DynamoDBMapperConfig config ) { config = mergeConfig ( config ) ; String tableName = getTableName ( clazz , config ) ; // Fill in the hash key element in the service request Method hashKeyGetter = reflector . getHashKeyGetter ( clazz ) ; AttributeValue hashKeyElement = getHashKeyElement ( hashKey , hashKeyGetter ) ; // Determine the range key, if provided AttributeValue rangeKeyElement = null ; if ( rangeKey != null ) { Method rangeKeyMethod = reflector . getRangeKeyGetter ( clazz ) ; if ( rangeKeyMethod == null ) { throw new DynamoDBMappingException ( "Zero-parameter range key property must be annotated with " + DynamoDBRangeKey . class ) ; } rangeKeyElement = getRangeKeyElement ( rangeKey , rangeKeyMethod ) ; } GetItemResult item = db . getItem ( applyUserAgent ( new GetItemRequest ( ) . withTableName ( tableName ) . withKey ( new Key ( ) . withHashKeyElement ( hashKeyElement ) . withRangeKeyElement ( rangeKeyElement ) ) . withConsistentRead ( config . getConsistentReads ( ) == ConsistentReads . CONSISTENT ) ) ) ; Map < String , AttributeValue > itemAttributes = item . getItem ( ) ; if ( itemAttributes == null ) { return null ; } return marshallIntoObject ( clazz , itemAttributes ) ; }
Returns an object with the given hash key or null if no such object exists .