-->
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.  [ 3 posts ] 
Author Message
 Post subject: object references an unsaved transient instance
PostPosted: Wed Jun 30, 2004 12:11 pm 
Newbie

Joined: Wed Jun 30, 2004 12:01 pm
Posts: 3
Hello, I am using spring framework with HibernateSupport

Step_State table has composite-id and is a foreign key to CONTENT Table

So Ihave collection of contents defined in the StepState Class

what should i do to resolve unsaved transient instance ? hibernate saves into STEP_STATE table but does not save into Content table..

I am using saveOrUpdate(stepstateObject)


(hibernate.HibernateTransactionManager 315 ) Initiating transaction commit
Hibernate: insert into CBMCON00 (CON_CNTNT_OBJ, CON_INSERT_TMS, CON_CNTNT_TYPE_CDE, CON_GROUP_ID, CON_WRK_SESSION_ID, CON_STEP_ID) values (?, ?, ?, ?, ?, ?)
(impl.SessionImpl 2368) Could not synchronize database state with session
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.test.groupstate.hibernate.StepState
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2759)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2751)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:46)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:154)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:399)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2360)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:386)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:316)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:189)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148)
at $Proxy0.createContent(Unknown Source)
at com.medco.groupadd.groupstate.junit.DaoTest.testCreateContent(DaoTest.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:72)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 12:19 pm 
Beginner
Beginner

Joined: Sat Oct 18, 2003 10:19 am
Posts: 21
Location: Belgium
an object associated with the object you are saving is not saved first.
save it first manually are use the cascade="save-update" functionality.

_________________
Koen Maes
Leuven, Belgium


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 12:33 pm 
Newbie

Joined: Wed Jun 30, 2004 12:01 pm
Posts: 3
in stepState mapping file I have he following
.. should i chjange from cascade="all" to cascade="save-update" ?
<set
name="contents"
lazy="false"
inverse="true" cascade="all"
>
<meta attribute="field-description">
@hibernate.set
lazy="false"
inverse="true"

@hibernate.collection-key
column="CON_GROUP_ID"
@hibernate.collection-key
column="CON_WRK_SESSION_ID"
@hibernate.collection-key
column="CON_STEP_ID"

@hibernate.collection-one-to-many
class="com.test.groupstate.hibernate.Content"
</meta>
<key>
<column name="CON_STEP_ID" />
<column name="CON_WRK_SESSION_ID" />

<column name="CON_GROUP_ID" />
</key>
<one-to-many
class="com.test.groupstate.hibernate.Content"
/>

</set>

below is content table mapping
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<class
name="com.testgroupstate.hibernate.Content"
table="CBMCON00"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="CBMCON00"
</meta>

<composite-id name="contentPK"
class="com.test.groupstate.hibernate.ContentPK" unsaved-value="any">
<meta attribute="class-description" inherit="false">
@hibernate.id
generator-class="assigned"

</meta>
<key-property
name="contentTypeCode"
column="CON_CNTNT_TYPE_CDE"
type="java.lang.Integer"
length="5"
>
<meta attribute="field-description">
@hibernate.property
column="CON_CNTNT_TYPE_CDE"
length="5"
</meta>
</key-property>
<!-- bi-directional many-to-one association to Cbmsts00 -->
<key-many-to-one
name="stepState"
class="com.test.groupstate.hibernate.StepState"
>
<meta attribute="field-description">
@hibernate.many-to-one
column="CON_GROUP_ID""
</meta>
<meta attribute="field-description">
@hibernate.many-to-one
column="CON_WRK_SESSION_ID""
</meta>
<meta attribute="field-description">
@hibernate.many-to-one
column="CON_STEP_ID""
</meta>
<column name="CON_GROUP_ID" />

<column name="CON_WRK_SESSION_ID" />
<column name="CON_STEP_ID" />

</key-many-to-one>
</composite-id>
<!--
<timestamp column="CON_INSERT_TMS" name="insertTms" unsaved-value="null">
</timestamp>
-->

<property
name="contentObj"
type="java.lang.String"
column="CON_CNTNT_OBJ"
not-null="true"
length="100"
>
<meta attribute="field-description">
@hibernate.property
column="CON_CNTNT_OBJ"
length="100"
not-null="true"
</meta>
</property>


<property
name="insertTms"
type="timestamp"
column="CON_INSERT_TMS"
not-null="true"
length="26"
>

<meta attribute="field-description">
@hibernate.property
column="CON_INSERT_TMS"
length="26"
not-null="true"
</meta>
</property>




<!-- associations -->

</class>
</hibernate-mapping>


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

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.