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?
|