• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sorting problem  RSS feed

Meelan emp
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!