Forums Register Login

Sorting problem

+Pie Number of slices to send: Send
Hi guys, my first post, welcome.

Anyway, let's get to the point - sorting problem.
I have many to many connection between two tables, and one join table for them:

teachers(teacherid serial, first_name varchar(50), last_name varchar(50));
classes(classid serial, class_name varchar(30));
teachers_classes(id serial, teacherid int, classid int);

Hibernate mapping:

In Teacher.hbm.xml:


In Class.hbm.xml



As you can see, i'm ordering by classId atm, but what i really need is ordering by className. Of course, i can't put that instead of classId in Teacher.hbm.xml because join table doesn't have className.
One of the solutions would be to order returned set, but i'm looking for more elegant solution, to order directly in Hibernate. I googled, but didn't find anything appropriate.
What do you think?
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 719 times.
Similar Threads
what changes should i made in save method in one-to-many relationships
Many-to-Many Relation
Hibernate mapping problem
Validating Hibernate mapping file with -set- and -join- elements
[Hibernate] One-to-many batch updating?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:53:41.