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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -