use of com.amazonaws.services.simpledb.model.SelectRequest in project siena by mandubian.
the class SdbMappingUtils method buildQuery.
public static <T> SelectRequest buildQuery(Query<T> query, String prefix, StringBuffer domainBuf) {
Class<?> clazz = query.getQueriedClass();
String domain = getDomainName(clazz, prefix);
domainBuf.append(domain);
QueryOptionFetchType fetchType = (QueryOptionFetchType) query.option(QueryOptionFetchType.ID);
StringBuilder q = new StringBuilder();
switch(fetchType.fetchType) {
case KEYS_ONLY:
q.append(SELECT + ITEM_NAME + FROM + domain);
break;
case NORMAL:
default:
q.append(SELECT + ALL_COLS + FROM + domain);
break;
}
return new SelectRequest(buildFilterOrder(query, q).toString());
}
use of com.amazonaws.services.simpledb.model.SelectRequest in project siena by mandubian.
the class SdbPersistenceManager method rawGetByKeys.
protected <T> List<T> rawGetByKeys(Class<T> clazz, Iterable<?> keys) {
try {
StringBuffer domainBuf = new StringBuffer();
SelectRequest req = SdbMappingUtils.buildBatchGetQueryByKeys(clazz, keys, prefix, domainBuf);
checkDomain(domainBuf.toString());
req.setConsistentRead(isReadConsistent());
SelectResult res = sdb.select(req);
List<T> models = new ArrayList<T>();
SdbMappingUtils.mapSelectResultToListOrderedFromKeys(res, models, clazz, keys);
// join management
if (!ClassInfo.getClassInfo(clazz).joinFields.isEmpty()) {
mapJoins(models);
}
return models;
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
}
use of com.amazonaws.services.simpledb.model.SelectRequest in project simplejpa by appoxy.
the class DomainHelper method selectItems.
/**
* Runs a query on the passed in domain with the passed in whereClause. If the nextToken is included for pagination.
*
* @param db
* @param domainName
* @param whereClause
* @param nextToken
* @param consistentRead true to read consistently, false to use eventual consistency
* @return
* @throws AmazonClientException
*/
public static SelectResult selectItems(AmazonSimpleDB db, String domainName, String whereClause, String nextToken, boolean consistentRead) throws AmazonClientException {
String selectExpression = "select * from `" + domainName + "`";
if (whereClause != null) {
selectExpression += " where " + whereClause;
}
SelectResult results = db.select(new SelectRequest().withConsistentRead(consistentRead).withSelectExpression(selectExpression).withNextToken(nextToken));
return results;
}
Aggregations