This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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


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.
 
GeeCON Prague 2014
 
subject: left join fetch returning unordered set