aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate problem" Watch "Hibernate problem" New topic
Author

Hibernate problem

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
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!?!?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate problem