org.hibernate.TransientObjectException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Two tables A and B where B is parent table and the relation between A and B is unidirectional many-to-one. mapping for A: <hibernate-mapping package="parms"> <class name="A" table="A" lazy="true" batch-size="20" select-before-update='true' > <id name="id" column="ID"> <generator class="increment"/> </id> <many-to-one name="b" column="Ba_ID" class="B" not-found="ignore" cascade="none" lazy="false" not-null="false" unique="false" /> <property name="place" column="PLACE"/> </class> mapping for B: <class name="B" table="B" lazy="true" batch-size="10" select-before-update="true"> <cache usage="read-write"/> <id name="id" column="B_ID" > <generator class="assigned"/> </id> <property name="programId" column="GROUP_ID" unique="true"/> </class> Also some of rows of table A have null values for column Ba_ID. Now retrieval of these rows which have null values for column Ba_ID works fine. And it retrieves a null relationship between the tables for these rows. Now when I try to update column PLACE. It tries to update column Ba_ID also and there it throws a TransientOBjectException. But nothing is being changed for that column. Also cascade is set to "none". Transaction scope code A a=_form.getA(id); a.setPlace("place"); sess.saveOrUpdate(a); tx.commit(); sess.close(); And the last SQL statement being tried to be executed is: UPDATE A set ......(all columns )..... where ID =? And the exception thrown is: [ERROR] AbstractFlushingEventListener - -Could not synchronize database state with session <org.hibernate.TransientObjectException: B> at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
    via by maxtor,
  • Two tables A and B where B is parent table and the relation between A and B is unidirectional many-to-one. mapping for A: <hibernate-mapping package="parms"> <class name="A" table="A" lazy="true" batch-size="20" select-before-update='true' > <id name="id" column="ID"> <generator class="increment"/> </id> <many-to-one name="b" column="Ba_ID" class="B" not-found="ignore" cascade="none" lazy="false" not-null="false" unique="false" /> <property name="place" column="PLACE"/> </class> mapping for B: <class name="B" table="B" lazy="true" batch-size="10" select-before-update="true"> <cache usage="read-write"/> <id name="id" column="B_ID" > <generator class="assigned"/> </id> <property name="programId" column="GROUP_ID" unique="true"/> </class> Also some of rows of table A have null values for column Ba_ID. Now retrieval of these rows which have null values for column Ba_ID works fine. And it retrieves a null relationship between the tables for these rows. Now when I try to update column PLACE. It tries to update column Ba_ID also and there it throws a TransientOBjectException. But nothing is being changed for that column. Also cascade is set to "none". Transaction scope code A a=_form.getA(id); a.setPlace("place"); sess.saveOrUpdate(a); tx.commit(); sess.close(); And the last SQL statement being tried to be executed is: UPDATE A set ......(all columns )..... where ID =? And the exception thrown is: [ERROR] AbstractFlushingEventListener - -Could not synchronize database state with session <org.hibernate.TransientObjectException: B> at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
    via by maxtor,
  • JTA | Our Craft
    via by Unknown author,
  • Hibernate Exception - Transient Object Exception
    via by Unknown author,
  • Hibernate One to many Mapping Error
    via Stack Overflow by Priyan RockZ
    ,
    • org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.gmv.sgi.agenda.core.modelo.contacto.UsuarioAgenda at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216) at org.hibernate.collection.AbstractPersistentCollection.getOrphans(AbstractPersistentCollection.java:889) at org.hibernate.collection.PersistentSet.getOrphans(PersistentSet.java:51) at org.hibernate.engine.CollectionEntry.getOrphans(CollectionEntry.java:328) at org.hibernate.engine.Cascade.deleteOrphans(Cascade.java:336) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:318) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108) at org.hibernate.engine.Cascade.cascade(Cascade.java:248) at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:410) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:299) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513) at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108) at org.hibernate.engine.Cascade.cascade(Cascade.java:248) at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:385) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:242) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513) at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:290) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108) at org.hibernate.engine.Cascade.cascade(Cascade.java:248) at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:410) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:299) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:509) at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:693) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366) at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:690) at com.gmv.sgi.sbcore.dao.hibernate.AbstractDAOHibernate.save(AbstractDAOHibernate.java:34) at com.gmv.sgi.sbcore.service.impl.BaseDAOService.save(BaseDAOService.java:43) at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176) at $Proxy1.save(Unknown Source) at com.gmv.sgi.agenda.core.service.basic.UsuarioBasicService.save(UsuarioBasicService.java:80) at com.gmv.sgi.agenda.core.service.high.UsuarioHighService.save(UsuarioHighService.java:194) at com.sgi.agenda.core.test.FirstTest.testSaveRecord(FirstTest.java:226) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,