I have an application where there is a parent with 10 children. Every children has composite keys(which includes the parent ID and a seq number).
I have a scenario where I need to display results 15 per page and allow user to sort by certain items(Couple of items are columns in child table).
I am able to achieve this functionality but performance is pretty bad. I am using Hibernate Criteria to retrieve all records first, sort them using java comparators and displaying on the page. Every click has an interaction with database.
EX:
Parent
A listing has listingID as primary key
Code Table
Beds --> bedID and Bed Name as columns
Child
ListingBeds --> listingID and BedID as composite key.
Code Table
Activities --> activityID and Activity Name as columns
Child
ListingActivities --> listingID and activityID as composite key.
Most of the columns that I am getting are from parent table and couple cols from child tables.
Best approach I think, is to use setFirstResult, setMaxResults and order by a column.
I did not find a way to order by a child column. Can anybody help me out in this regard.
Any help is greatly appreciated.
|