-->
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: criteria and sort
PostPosted: Sun Sep 21, 2008 3:06 pm 
Beginner
Beginner

Joined: Tue Jun 06, 2006 3:37 am
Posts: 29
Hi,

I would like to know if it's possible to sort a result from a criteria based on many to many relation (and normal column)

like I've an Affaire entity that contain representants
and I would like to sort (or order I think it's similar) like this way

Criteria.addOrder("participants.name")

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2008 2:35 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 3:37 am
Posts: 29
I'v tryed to create an alias for the collection

Code:
Criteria criteria = session.createCriteria(Affaire.class);
      criteria.createAlias("requerants", "affaire_requerant", CriteriaSpecification.LEFT_JOIN);
      criteria.addOrder(Order.desc("affaire_requerant.libelleFr"));


but I got the following exception

Code:
org.hibernate.QueryException: duplicate association path: requerants


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.