Fork me on GitHub

Sorted results with Hibernate

So I have a need to get the results from my DB in a sorted list. Hibernate provides a number of ways to do this.

I have implemented it in two ways

I have an Object called Rounds that has a property List. So when I load in the Rounds object and want the List to be sorted I do it in the hbm.xml file as follows.

The sorting is done by the order-by=“lower(game_id) asc”. Note that the lower(game_id) asc code is mysql specific and not hql.

The second way is to just use order by gameId in the query with in the Java code.

Tags: java, orm

blog comments powered by Disqus