-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to use @OrderBy with a composite key
PostPosted: Thu Jan 29, 2009 6:19 am 
Newbie

Joined: Mon Feb 12, 2007 6:57 am
Posts: 9
Hi,

I'd like to order my one-to-many collection by a field within my composite key. Specifically, something like this:

Code:
@OneToMany(mappedBy = "product", fetch = FetchType.EAGER)
@OrderBy("pk.dateOfValuation")
private Set<Valuation> valuations;


Alas Hibernate errors when I try this.

Code:
Caused by: org.hibernate.AnnotationException: property from @OrderBy clause not found: Valuation.pk.id


If I try just "pk" then it works fine. Can what I want be done?

Thanks

Nick[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2009 6:34 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
@OrderBy is the SQL-clause to be used, when fetching the collection. Have you tried just to put the column name of dateOfValuation (@OrderBy("dateOfValuation_column"))?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2009 9:32 am 
Newbie

Joined: Mon Feb 12, 2007 6:57 am
Posts: 9
No that doesn't work I'm afraid. It needs to be one of the persistant fields.

Code:
Caused by: org.hibernate.AnnotationException: property from @OrderBy clause not found: Valuation.DATE_OF_VALUATION


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2009 10:30 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Could you also provide code of your IdClass and your Valuation-class?

_________________
-----------------
Need advanced help? http://www.viada.eu


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