-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Exception while saving a table with mapping to view.
PostPosted: Fri Aug 10, 2007 12:43 pm 
Newbie

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.