java - How to get unique results from joined Hibernate queries -
this continuation questions this: why hibernate hql distinct cause sql distinct on left join?
you may have noticed findall()
repository methods return duplicates, while findall(pageble pageble)
works fine.
so, share additional way obtain unique results.
so, let's have @ org.hibernate.hql.internal.ast.querytranslatorimpl
final boolean haslimit = queryparameters.getrowselection() != null && queryparameters.getrowselection().defineslimits(); final boolean needsdistincting = ( query.getselectclause().isdistinct() || haslimit ) && containscollectionfetches();
as can see, hibernate apply distincting if define limits. is, if afraid of word distinct
in queries , criteria, call javax.persistence.query.setfirstresult(0);
, make hibernate apply distincting.
Comments
Post a Comment