-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria - small ordering problem
PostPosted: Sat Apr 07, 2007 9:20 am 
Newbie

Joined: Fri Apr 06, 2007 4:31 pm
Posts: 1
Helo, I have a next problem:

I execute next code for geting a List of required objects:
Code:
session
  .createCriteria(Manufacturer.class)
  .setFetchMode("modelLines", FetchMode.JOIN)
  .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
  .addOrder(Order.asc("name"))
  .list();


The objects Manufacturer ordering by "name" attribute. But also I need order joined "modelLines" objects in result by "modelLines.name" attribute.

I was try to add next:
Code:
  ...
  .addOrder(Order.asc("modelLines.name"))
  ...

but it's throw exception...
Code:
.... could not resolve property: modelLines.name ....


Please, answer me what I need to do. I think that my problem is very simple.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 4:51 pm 
Newbie

Joined: Tue Dec 12, 2006 5:01 am
Posts: 11
Please have a look on this thread and my proposed fix.

Regards
Joerg


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 10:14 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

session
.createCriteria(Manufacturer.class)
.setFetchMode("modelLines", FetchMode.JOIN)
.createAlias("modelLines", "mod") .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.addOrder(Order.asc("name").addOrder(Order.asc("mod.name"))
.list();


Amila

(Don't forget to rate if helps)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.