Joined: Fri Aug 10, 2007 12:21 pm Posts: 1
|
I have a table say "TABLE" and view say "VIEW". The id for the table is the id for thre view. The relationship is one-to-one both ways. The hibernate mappings look like this.
<hibernate-mapping package="com.mypackage">
<class name="Table" table="TABLE">
<id name="tableID" column="TABLE_ID" type="java.lang.Long">
<generator class="com.mypackage.IdGenerator"/>
</id>
<property name="prop1" column="PROP_1" type="java.lang.Long"/>
<one-to-one name="view" class="View"/>
</class>
</hibernate-mapping>
<hibernate-mapping package="com.mypackage">
<class name="View" table="VIEW">
<id name="tableID" column="TABLE_ID" type="java.lang.Long">
<generator class="foreign">
<param name="property">table</param>
</generator>
</id>
<property name="prop1" column="PROP_1" type="java.lang.Long"/>
<one-to-one name="table" class="Table"/>
</class>
</hibernate-mapping>
When I save the table, I get an exception with the following stack trace. Any help on this will be of greatly appreciated.
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.mypackage.View
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
at org.hibernate.type.EntityType.replace(EntityType.java:253)
at org.hibernate.type.AbstractType.replace(AbstractType.java:153)
at org.hibernate.type.TypeFactory.replaceAssociations(TypeFactory.java:530)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:366)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:195)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
at
--
Narayanan
|
|