-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: easier way to order by
PostPosted: Fri Apr 11, 2008 2:43 pm 
Newbie

Joined: Fri Apr 11, 2008 1:43 pm
Posts: 1
Hibernate version:3.2.6

I have the following mapping, when I have Circuit object, I can get users by circuit.getUsers(), which is sort by user id.

But in another jsp, I have to display users by user name.

I want to sort it on database level, I have to write another DAO or define another set mapping.

Is there a easier way?

Thanks a lot.

Code:
<hibernate-mapping>
   <class name="arden.persistence.model.Circuit" table="df_gym_circuit">
...
<set name="users" inverse="false" table="df_gym_user_circuit" order-by="user_id asc">
         <key>
            <column name="circuit_id" not-null="true" />
         </key>
         <many-to-many entity-name="arden.persistence.model.User">
            <column name="user_id" not-null="true" />
         </many-to-many>
      </set>
...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 2:51 pm 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Use criteria.

Code:
Session.createCriteria(Circuit.class).addOrder(Order.asc("username") )

_________________
Sukirtha


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.