Hibernate Criteria Duplicate Records Issue [Solved]

Hibernate Criteria Duplicate Records Issue:
Duplicate same records with hibernate join.

In Hibernate if we did join, we may get duplicates sometime.

Below are the possible ways to resolve the duplicate same record value issue,

Possible Solutions:
1. criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
2. criteria.setProjection(Projections.distinct(Projections.property(“id”)));
3. criteria.setProjection(Projections.distinct(Projections.id()));

Recommended Solution:


If nothing is working then change the list to set, so that duplicates will be avoided from java side.

Hibernate Recommended Books:

Feel free to post your comments/feedbacks..

538 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *