aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate With Spring - Performance Issue" Watch "Hibernate With Spring - Performance Issue" New topic
Author

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
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

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: http://www.jroller.com/page/kbaum?entry=orm_lazy_initialization_with_dao

Good luck!


--James
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 ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate With Spring - Performance Issue
 
Similar Threads
Spring and Hibernate ... i am confuse
Hibernate one-to-many weirdness...
Bi-directional mapping problems while creating tables on runtime
OpenSessionInViewFilter does not help, Spring + Hibernate
Bi-directional mapping problems while creating tables on runtime