List of usage examples for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBMapper load
@Override
public <T> T load(Class<T> clazz, Object hashKey, DynamoDBMapperConfig config)
From source file:org.apache.gora.dynamodb.store.DynamoDBNativeStore.java
License:Apache License
@Override /**// ww w .j a va2 s . c o m * Gets the object with the specific key * @throws IOException */ public T get(K key) throws GoraException { T object = null; try { Object rangeKey; rangeKey = getRangeKeyFromKey(key); Object hashKey = getHashFromKey(key); if (hashKey != null) { DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBStoreHandler.getDynamoDbClient()); if (rangeKey != null) object = mapper.load(persistentClass, hashKey, rangeKey); else object = mapper.load(persistentClass, hashKey); return object; } else { throw new GoraException("Error while retrieving keys from object: " + key.toString()); } } catch (GoraException e) { throw e; } catch (Exception e) { throw new GoraException(e); } }
From source file:org.apache.gora.dynamodb.store.DynamoDBNativeStore.java
License:Apache License
/** * Puts an object identified by a key// w ww . j ava 2s . co m * * @param key * @param obj */ @Override public void put(K key, T obj) throws GoraException { try { Object hashKey = getHashKey(key, obj); Object rangeKey = getRangeKey(key, obj); if (hashKey != null) { DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBStoreHandler.getDynamoDbClient()); if (rangeKey != null) { mapper.load(persistentClass, hashKey, rangeKey); } else { mapper.load(persistentClass, hashKey); } mapper.save(obj); } else throw new GoraException("No HashKey found in Key nor in Object."); } catch (Exception e) { throw new GoraException(e); } }