Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Object Relational Mapping and the fly likes Hibernate With Spring - Performance Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate With Spring - Performance Issue" Watch "Hibernate With Spring - Performance Issue" New topic

Hibernate With Spring - Performance Issue

Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
It uses HibernateDAOTemplate to handle the session..Hibernate runs lot of sql statements in the beginning and traverses the whole object graph ( parent -child ) and retrieves all of the objects.. My problem is that i tried to make it lazy ..tried to set up the batch size but all things ended with exceptions ...if i make all mappings lazy then i am getting Session Closed exception ..I am seeing the call in web service at this point..and it looks like some thing is triggered outside the context..for the batch size setting .. I am getting XYZ object not found at runtime...My question is what should i do to improve the performance and what guidelines i should follow ..I don't know much about Hibernate -Spring

SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10067

In order to improve the performance you will have to get the lazy loading working(which is quite a task in itself, in an existing application. Merely setting lazy=true in the mapping wont always get it working). Spring provides OpenSessionInViewFilter which you can use in your application. But before doing that you might want to read some more articles about how lazy loading works in Hibernate. One of them is this.
[ December 26, 2006: Message edited by: Jaikiran Pai ]

[My Blog] [JavaRanch Journal]
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I'm not sure if this is relevant to your problem, but just in case you might want to look into using Spring's OpenSessionInViewFilter and/or OpenSessionInViewInterceptor. Here's a good article about this:

Good luck!

Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
Thanks James & pai .. I will try that and will let you know if i have any issues( I am sure i will have )
Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
can any one give me some good article about defining the relationship - associations for the classes/mappings. Does the Assciations make difference while loading up the whole object graph .. How to distinguish whether uni directional association is needed or Bi directional ??
It is sorta covered in the JavaRanch Style Guide.
subject: Hibernate With Spring - Performance Issue