-->
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: Nested order-by's for collection mappings?
PostPosted: Wed Jun 08, 2005 6:02 pm 
Newbie

Joined: Fri Jun 25, 2004 9:05 pm
Posts: 13
I am currently working on a project that uses OJB, and we are thinking about moving it to Hibernate. I am doing a gap-analysis to make sure that all the features we need is supported in Hibernate 3.

I have ran across one that I am not sure if it is possible.

With OJB, inside the mapping for a collection, you can define the order-by with dot-notation nested path's, and the generated query will do the joins.

My my reading of Hibernate's order-by attribute for set's and bag's, it looks like you have to specify the db column, and it would only be applicable to column's that are part of the element class for the collection.

To clarify, here is a contrived example.

Suppose I have an object named FelineStudy.

FelineStudy has a collection named felines, of object's named Feline.

A Feline object has a one-to-one reference to an object named a Heart.

A Heart object has value type on it named AverageHeartRate.

Using OJB, on the Collection mapping for felines inside the Class Mapping for FelineStudy, I could add an order-clause that looked like this: 'order-by=heart.averageHeartRate'. (since it is of type feline, it works from that level to walk the properties)

This meant any time a FelineStudy was created, the collection of felines would be materialzed with the felines being in order of their hearts averageHeartRate. This was for all FelineStudies.

As I said, it looks like Hiberanate's order-by attribute on Set is limited since it would not know about the join semantics to accomplish this. It looks to me like the values I would be able to order the felines on would be properties on the Feline object itself.

Note: this is not solvable by using either HSQL or Criteria (which we would probably use), as the query would be for objects of type FelineStudy, and the desire is the ordering 3 levels down.

Is this possible to do?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 6:56 am 
Regular
Regular

Joined: Wed May 05, 2004 8:01 am
Posts: 53
This is not possible IMO. Still you can use other constructs to achieve the same goal. Have a look at http://forum.hibernate.org/viewtopic.php?t=946032&highlight=


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.