Hi all,
i'm sitting here on a pretty weird problem and could need some help or ideas. I have two model classes (Course and Participants) and one association class (takes_part) for storing many-to-many links with additional attributes. The structure is as follows:
Course --- many-to-one ---> takes_part <--- many-to-one --- Participants
Now it is that i need to get the participants of a course and the other way round, the courses of a participant. Currently i have a hibernate.set in both Course and Participant pointing at takes_part:
Code:
...
/**
* @hibernate.set inverse="true" group-by="WITH THAT I CAN ONLY ORDER BY KEYS IN THE ASSOCIATION-TABLE"
* @hibernate.collection-key ...
* @hibernate.collection-many-to-one class="TakesPart"
...
The problem is that i would like to order this set by the other end. E.g. when retrieving the participants of a course i'd like to order them by there names. Currently i can only order the collection by keys that are available directly in the association class takes_part, but not by a key in the other class. (I hope i explained this well enough. As you might have noticed, i'm not a native speaker.. ;-)
I've already looked at composite-elements, but they are pretty unintuitive and if i got the docs right, they are not bi-directional.
Is there an elegant way to order the contents of this set? In raw SQL this would be quite easy:
Code:
select * from Course as c, takes_part as t, Participant as p where c.id = SOMEID and t.course_id = c.id and p.id = t.person_id order by p.name
Btw. i'm using Hibernate 3.1 with a MySql server.
Many thanks in advance. :-D