Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting unique result in Hibernate

how can we get distinct result by using criteria in hibernate.

like image 877
Shashi Avatar asked May 27 '09 11:05

Shashi


2 Answers

A more flexible solution may be:

criteria.setProjection(Projections.distinct(Projections.property("property")));
like image 39
waxwing Avatar answered Sep 16 '22 14:09

waxwing


criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

See also https://forum.hibernate.org/viewtopic.php?t=941669

like image 189
trunkc Avatar answered Sep 19 '22 14:09

trunkc