return (Integer) Atom.getFirstOrThrow(queryInTransaction(query, session));
}
public Collection<Object> findByPropertyRange(final String propertyName, final Object minValue, final Object maxValue, final Integer firstResult, final Integer maxResults) {
// Use an AllShardsresolutionStrategy + Criteria
final EntityConfig entityConfig = config;
final EntityIndexConfig indexConfig = config.getEntityIndexConfig(propertyName);
Session session = factory.openAllShardsSession();
QueryCallback callback;
if (isPrimitiveCollection(propertyName)) {
callback = new QueryCallback() {
@SuppressWarnings("unchecked")
public Collection<Object> execute(Session session) {
Query query = session.createQuery(String.format("from %s as x where %s between (:minValue, :maxValue) order by x.%s asc limit %s, %s",
entityConfig.getRepresentedInterface().getSimpleName(),
indexConfig.getIndexName(),
entityConfig.getIdPropertyName(),
firstResult,
maxResults)
).setEntity("minValue", minValue).setEntity("maxValue", maxValue);
return query.list();
}