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.foo.server.model.house.conditioning.Duct at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242) at org.hibernate.collection.AbstractPersistentCollection.getOrphans(AbstractPersistentCollection.java:919) at org.hibernate.collection.PersistentList.getOrphans(PersistentList.java:70) at org.hibernate.engine.CollectionEntry.getOrphans(CollectionEntry.java:373) at org.hibernate.engine.Cascade.deleteOrphans(Cascade.java:364) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:348) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:266) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:243) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193) at org.hibernate.engine.Cascade.cascade(Cascade.java:154) at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:154) at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:145) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028) at com.foo.server.services.db.Transaction.commit(Transaction.java:28)

    Users with the same issue

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