File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes left join fetch returning unordered set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "left join fetch returning unordered set" Watch "left join fetch returning unordered set" New topic
Author

left join fetch returning unordered set

bagaria kushal
Greenhorn

Joined: Mar 29, 2011
Posts: 19
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

Joined: Jun 24, 2011
Posts: 12

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

Joined: Mar 29, 2011
Posts: 19
thanks a lot.
That problem is resolved. I used @OrderBy anotation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: left join fetch returning unordered set