[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2097) LAZY property results in org.hibernate.TransientObjectException after merge

Reto Urfer (JIRA) noreply at atlassian.com
Fri Sep 22 10:41:24 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2097?page=comments#action_24596 ] 

Reto Urfer commented on HHH-2097:
---------------------------------

some additional information:

if you set cascade to either PERSIST or ALL, the Testapplication works without exception.

if you set cascade to MERGE, the Testapplication still throws the exception. This seems strange for me, because i only called the merge function which should not be influenced by the PERSIST flag,no?

> LAZY property results in org.hibernate.TransientObjectException after merge
> ---------------------------------------------------------------------------
>
>          Key: HHH-2097
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2097
>      Project: Hibernate3
>         Type: Bug

>   Components: core
>     Versions: 3.2.0.cr4
>  Environment: Hibernate3.2 cr4 with Annotations cr2 and EntityManager cr2, Oracle10g R2, WindowsXP
>     Reporter: Reto Urfer
>     Priority: Critical
>  Attachments: BugLazyPropertyMerge.zip
>
>
> Entity1 has a property e2 which references Entity2. This property is defined as follows.
>      @ManyToOne(fetch = FetchType.LAZY, optional = false)
>      private Entity2 e2;
> If you have an instance e1 of Entity1 which has not initialized property e2 and you merge e1 to the EntityManager within a transaction, then you get the following exception during commit:
> Exception in thread "main" javax.persistence.RollbackException: Error while commiting the transaction
> 	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:63)
> 	at com.test.Test.main(Test.java:42)
> Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.test.Entity1.e2 -> com.test.Entity2
> 	at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:350)
> 	at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
> 	at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:130)
> 	at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
> 	at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
> 	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
> 	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> 	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> 	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
> 	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:53)
> 	... 1 more
> I added a small Testproject to reproduce this bug.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list