public RootHibernateQuery interpret( ObjectQuery query, Class<? extends Containerable> type, Collection<SelectorOptions<GetOperationOptions>> options, PrismContext prismContext, boolean countingObjects, Session session) throws QueryException { Validate.notNull(type, "Type must not be null."); Validate.notNull(session, "Session must not be null."); Validate.notNull(prismContext, "Prism context must not be null."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Interpreting query for type '{}', query:\n{}", new Object[] {type, query}); } InterpretationContext context = new InterpretationContext(this, type, prismContext, session); interpretQueryFilter(context, query); interpretPagingAndSorting(context, query, countingObjects); RootHibernateQuery hibernateQuery = context.getHibernateQuery(); if (countingObjects) { hibernateQuery.addProjectionElement(new ProjectionElement("count(*)")); } else { String rootAlias = hibernateQuery.getPrimaryEntityAlias(); hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".fullObject")); // TODO other objects if parent is requested? if (context.isObject()) { hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".stringsCount")); hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".longsCount")); hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".datesCount")); hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".referencesCount")); hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".polysCount")); hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".booleansCount")); hibernateQuery.setResultTransformer(GetObjectResult.RESULT_TRANSFORMER); } else { hibernateQuery.addProjectionElement(new ProjectionElement(rootAlias + ".ownerOid")); hibernateQuery.setResultTransformer(GetContainerableResult.RESULT_TRANSFORMER); } } return hibernateQuery; }