Hi,
How to clone criteria object?
I have created Criteria object for joining multiple tables and applying multiple restrictions. Then i need total number of records based on the restrictions applied.Then i need to apply pagination details(by set maxList) and have to retrive List of Objects.
Criteria criteria = session.createCriteria(Property.class, "property")
.createAlias("property.propertyType", "type").createAlias(
"property.propertyConcern", "propertyConcern",
CriteriaSpecification.LEFT_JOIN).createAlias(
"propertyConcern.concern", "concern",
CriteriaSpecification.LEFT_JOIN).setResultTransformer(
CriteriaSpecification.DISTINCT_ROOT_ENTITY);
criteria = addMultipleSeachCriteria(criteria, condition);
criteria.setFirstResult(
pageCriteria.getFirstRecordOfCurrentPage())
.setMaxResults(pageCriteria.getRecordsPerPage());
criteria.addOrder(pageCriteria.isSortDescending() ? Order
.desc(pageCriteria.getSortBy()) : Order
.asc(pageCriteria.getSortBy()));
When i run this i getting results as i expected. But i need to fetch number of records for the applied restrictions without applying order by and setmaxResults.?How do i achieve?I am not able clone the criteria object also..