• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

left join fetch returning unordered set

 
bagaria kushal
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a query like
from employee emp left join fetch emp.empnm left join fetch emp.xyz where emp.name=something;


where emp.empnm and emp.xyz may return a list of objects.

so emp.empnm and emp.xyz returns me an unordered set. i want it to be ordered.
how can i achieve this???
 
Aymen Benhmida
Greenhorn
Posts: 12
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have two choices here:
either you make hibernate order the result using the orderBy in the hql query or the the criteria whatever you are using.
or you can extract the result then put it in an orderedSet using a comparator.
but the first solution is best either for performance and for application quality. Since you delegate to db what it is doing best.
 
bagaria kushal
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot.
That problem is resolved. I used @OrderBy anotation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic