Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate With Spring - Performance Issue

 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic