Update: Please use our updated Hibernate Criteria Builder objects instead so you can have much more control, granularity and coolness!
Get the record count using hibernate projections and criterion for specific queries
Returns
This function returns numeric
Arguments
Examples
// The following is handler code which has been wired with a virtual entity serviceproperty name="authorService" inject="entityService:Author";functionshowAuthors(event){var rc =event.getCollection();// Get the hibernate restrictions proxy objectvar restrictions =authorService.getRestrictions();// build criteriavar criteria = [];// Apply a "greater than" constraint to the named propertyArrayAppend(criteria,restrictions.ge("firstName","M"));// Get the criteria query first prc.example1 = authorService.criteriaQuery(criteria=criteria, offset=(prc.boundaries.STARTROW-1), max=getSetting("PagingMaxRows"), sortOrder="firstName ASC");
// get the total records found via projectionsprc.foundcount =authorService.criteriaCount(criteria=criteria);}
Key
Type
Required
Default
Description
entityName
any
Yes
---
The entity to run count projections on
criteria
array
No
[]
The array of hibernate criterion to use for the projections