File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LazyInitializationException(Spring-Hibernate application)

 
VenkataPrasad Regula
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have got two methods in spring-hibernate project. 1)empadd() and 2) empget(). As I execute, the firstone gets executed and for the second one it says LazyInitialization exception. This means the session is getting closed after the first method is executed. To make both the methods run in the same session, I was guided to use OpenSessionInViewInterceptor. This is not a web application. It is a 2-tier application. I am finding on google the class of OpenSessionInViewInterceptor, but I am not knowing how to use it from the client code. What all I need is the same session to be for both the methods.
 
VenkataPrasad Regula
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone give a simple but complete sample code. Thanks in advance.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your transaction boundary. A session is "scoped" to a single transaction, single user, single use case. If you have a use case that covers more than one query, you have to make sure it is still all done in one transaction and one session. Once a transaction is committed, the session is over and done.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic