String tableName = ( (OgmEntityPersister) ( sessionImplementor
.getFactory() )
.getEntityPersister( result.getEntityType().getName() ) )
.getTableName();
NoSQLQuery query = new NoSQLQueryImpl(
new MongoDBQueryDescriptor(
tableName,
Operation.FIND, //so far only SELECT is supported
result.getQuery(),
result.getProjection(),
result.getOrderBy()
),
sessionImplementor,
new ParameterMetadata( null, null )
);
// Register the result types of the query; Currently either a number of scalar values or an entity return
// are supported only; JP-QL would actually a combination of both, though (see OGM-514)
if ( result.getProjection() != null ) {
for ( String field : result.getProjection().keySet() ) {
query.addScalar( field );
}
}
else {
query.addEntity( result.getEntityType() );
}
return query;
}