Please help me with this.
Im using detached criteria to get the total number of customers.
In my CustomerDaoImpl:
@Override
public int getCustomerSize() {
DetachedCriteria dc = getDetachedCriteria();
dc.setProjection(Projections.count("customerId"));
// I need to return only the count result.
return 0;
}
Usually what I do is I get the results, store in a collection and use the collection.size
. I don't think its efficient for I have to fetch the unnecessary data just to get the count
. Please help.