Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate problem

Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, constantly I have a problem of throwing LazyInitializationException.

Either if I use a Spring or low-level comunication with database the mentioned exception is thrown whenever
I try to retrieve an object using -- load(Class klass, id) --.
If I try to retrieve using createQuery(...) method it's than ok, no exception occurs.
Here is the portion of code where I try to retrieve an object using Spring integration :

Where ImprovedEventDao extends abstract class AbstractSpringDao, which extends HibernateDaoSupport :

In low level db comunication, my method for storing and retrieving object is :

where startoperation() mmethond perform obtaining SessionFactory, Sesion and Transaction. Also I get the mentioned
Exception. What is the problem? If I not close session after inserting data, and not commit second startoperation() and
commit() method, I do not get an exception, neither if I use createQuery() method.. But then, two distinct operation occurs during the same session!?
If I use Spring, there is no choice, and each operation will occurs in context of particular Session and Transaction.
so what is the problem!?!?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic