-->
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: problems with order-by and Collections
PostPosted: Mon Mar 22, 2004 8:15 am 
Newbie

Joined: Fri Mar 19, 2004 12:30 pm
Posts: 8
Hi all,

I am having the following problem with hibernate using the order-by attribute in the Collection specification/Mapping. I have a field createdOn in a generic class A. Now I have two classes B and C that extend A (They are in different packages and I have them as joined subclasses of A). My class B has a one to many asociation with C. So in the mapping of the assoiation from B to C I have a method to retieve all C's of B. I have used the order-by attribute to sort the collection on creadtedOn field. However, at runtime I get the following Exception No such attribute C0_.createdon found for Class C. C inherits this attribute from A so why should this not work. I currently have removed the order-by attribute and after fetching the List, I order it using a Comparator. However, I dont like this approach and would like the order by to be performed at the time the query is executed. Does anybody have a solution to this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 10:50 am 
Newbie

Joined: Fri Mar 19, 2004 12:30 pm
Posts: 8
I wrote a query to do what I needed. Hoewever, I did not succeed with the order-by attribute of the the one to many relation mapping of the Collection. I even tried to give the fully qualified path name of the attribute in the superclass but I still got an sql exception. I am using xdoclet.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 10:56 am 
Newbie

Joined: Fri Mar 19, 2004 12:30 pm
Posts: 8
Found out that value of order-by is an SQL ordering and NOT and HQL ordering that why it throws an Exception. That's why the createQuery/ createCriteria worked.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 31, 2004 7:21 pm 
Regular
Regular

Joined: Wed Dec 17, 2003 1:58 pm
Posts: 102
Conrad I've been having the exact same problem, how did you end up solving it? The two scenarios I've had problems with:

Concrete Class A
Concrete Class B extends A, has its table with the extended parameters

Impossible to load a set of B with an order-by statement containing inherited parameters from A.


Another problem I've run into is when using a many-to-many relationship from Object A->B, loaded into a set, if I try to do an order-by statement on that set it fails, trying to call a parameter from the table holding object A! Very strange..

Any insight into how you solved it would be appreciated!
-David


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.