What are Projections in Hibernate?
Answered
What are Projections in Hibernate?
Best answer
Projections API is introduced as part of Criteria API which is used to load partial object from database and to find the result of aggregate functions. Projection is an interface and Projections class is similar to Restrictions class and provides a set of static factory methods for producing Projection instances.
..... Criteria cr = session.createCriteria(Student.class); // To get total row count cr.setProjection(Projections.rowCount()); // To get distinct count of a property cr.setProjection(Projections.countDistinct("studentName")); .....