Hibernate version: 3.1.2
Hi Everyone,
My problem is the following:
I'm working on a 3 tier application. I use services that I developped to persit data. I've got a problem with entity A that I load, modify and then merge.
The merge return a detached object and my hibernate session is closed.
Before the merge I can acces B data from A.
So when I want to acces the entity B related object of A after the merge, I' ve got the following message/error:
ERROR LazyInitializationException:19 - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at B$$EnhancerByCGLIB$$fa2fcb9e_4.toString(<generated>)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
The link between A and B is a unidrectionnal one to one link mapped like this (on FK):
A.hbm.xml
Code:
<many-to-one name="B" entity-name="B" column="B_ID" unique="true"/>
How can I do to have B data linked after the merge on A?
I tried one-to-one link between A and B but I don't want to load B when I'm loading A (that one-to-one do, I didn't find anything to load lazily on a one-to-one)?
Realy need some help on this, searched a lot, found nothing.
Please.
Vision