use of com.qcadoo.model.internal.search.SearchCriteria in project qcadoo by qcadoo.
the class DataAccessServiceImpl method find.
@Override
@Transactional(readOnly = true)
@Monitorable
public SearchResult find(final SearchCriteria searchCriteria) {
checkArgument(searchCriteria != null, "SearchCriteria must be given");
Criteria criteria = searchCriteria.createCriteria(hibernateService.getCurrentSession());
int totalNumberOfEntities = hibernateService.getTotalNumberOfEntities(criteria);
if (totalNumberOfEntities == 0) {
LOG.debug("There is no entity matching criteria " + searchCriteria);
return getResultSet(null, totalNumberOfEntities, Collections.emptyList());
}
searchCriteria.addFirstAndMaxResults(criteria);
searchCriteria.addOrders(criteria);
searchCriteria.addCacheable(criteria);
List<?> results = hibernateService.list(criteria);
if (LOG.isDebugEnabled()) {
LOG.debug("There are " + totalNumberOfEntities + " entities matching criteria " + searchCriteria);
}
InternalDataDefinition searchQueryDataDefinition = (InternalDataDefinition) searchCriteria.getDataDefinition();
if (searchQueryDataDefinition == null) {
searchQueryDataDefinition = hibernateService.resolveDataDefinition(criteria);
}
return getResultSet(searchQueryDataDefinition, totalNumberOfEntities, results);
}
Aggregations