*/
@Override
public List find(List<IndexClause> ixClause, EntityMetadata m, boolean isRelation, List<String> relations,
int maxResult, List<String> columns)
{
Selector selector = clientFactory.getSelector(pool);
SlicePredicate slicePredicate = Selector.newColumnsPredicateAll(false, Integer.MAX_VALUE);
if (columns != null && !columns.isEmpty())
{
slicePredicate = Selector.newColumnsPredicate(columns.toArray(new String[] {}));
}
List<Object> entities = new ArrayList<Object>();
if (ixClause.isEmpty())
{
if (m.isCounterColumnType())
{
try
{
IPooledConnection connection = getConnection();
org.apache.cassandra.thrift.Cassandra.Client thriftClient = connection.getAPI();
List<KeySlice> ks = thriftClient.get_range_slices(new ColumnParent(m.getTableName()),
slicePredicate, Selector.newKeyRange("", "", maxResult), getConsistencyLevel());
connection.release();
entities = onCounterColumn(m, isRelation, relations, ks);
}
catch (InvalidRequestException irex)
{
log.error("Error during executing find, Caused by: .", irex);
throw new PersistenceException(irex);
}
catch (UnavailableException uex)
{
log.error("Error during executing find, Caused by: .", uex);
throw new PersistenceException(uex);
}
catch (TimedOutException tex)
{
log.error("Error during executing find, Caused by: .", tex);
throw new PersistenceException(tex);
}
catch (TException tex)
{
log.error("Error during executing find, Caused by: .", tex);
throw new PersistenceException(tex);
}
}
else
{
if (m.getType().isSuperColumnFamilyMetadata())
{
Map<Bytes, List<SuperColumn>> qResults = selector.getSuperColumnsFromRows(m.getTableName(),
selector.newKeyRange("", "", maxResult), slicePredicate, getConsistencyLevel());
entities = new ArrayList<Object>(qResults.size());
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
EntityType entityType = metaModel.entity(m.getEntityClazz());
List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();
for (Bytes key : qResults.keySet())
{
onSuperColumn(m, isRelation, relations, entities, qResults.get(key), key.getBytes());
}
}
else
{
Map<Bytes, List<Column>> qResults = selector.getColumnsFromRows(m.getTableName(),
selector.newKeyRange("", "", maxResult), slicePredicate, getConsistencyLevel());
entities = new ArrayList<Object>(qResults.size());
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
EntityType entityType = metaModel.entity(m.getEntityClazz());
List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();
for (Bytes key : qResults.keySet())
{
onColumn(m, isRelation, relations, entities, qResults.get(key), subManagedType, key.getBytes());
}
}
}
}
else
{
entities = new ArrayList<Object>();
for (IndexClause ix : ixClause)
{
Map<Bytes, List<Column>> qResults = selector.getIndexedColumns(m.getTableName(), ix, slicePredicate,
getConsistencyLevel());
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());