Hi all,
Lets assume, I have a db design with the following relationship.
University table contains university details.
Course table contains course details along with an association to university.
Instructor table contains instructor details, this table also has an association with university.
In my hibernate mapping files, especially on the university table, I have a one to many association to course and instructor records with lazy loading enabled.
On my GUI, Whenever the user searches for an university and opens it, I am displaying all the information related to university like courses,instructors associated with this university.
As per hibernate documentation, We can retrieve the collection objects only if the session in in open state(Lazy loading enabled).
Assuming a layered architecture, my model objects has to be transferred to the form objects and send it back to the
jsp page to be displayed.
I am doing this transfer of objects when the session is open state,So all the collection objects are transferred to form objects, but during this step, Hibernate goes in and executes the SQL's to get the collection objects.
Now coming to the problem. Assume that an university has 100 courses and 100 instructors, so when i want to view the information of this university, system is taking too long to respond because, hibernate usually executes only 1 select statement to retrieve the university record, but when i transfer the objects from model to form with hibernate session in open state,hibernate is executing select statements to retrieve course and instructor records.
Please let me know, how to solve this kind of performance problem with hibernate.
Thanks,
Shyam.