-->
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: TransientObjectException:object references unsaved transient
PostPosted: Tue Mar 11, 2008 11:57 pm 
Newbie

Joined: Sat Mar 08, 2008 6:35 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi Everybody i am facing an issue with hibernate. I have written two classes Company(Parent Object)and DBDCDeliveryAddress(child object) with the following mapping properties.

When i tried to save the parent (attaching the child data), i am getting
the following exception

net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:
Could you please look into this and resolve this.

Thanks inAdvance.



Hibernate version: 2.1.7

Mapping documents:
Company Mapping file
<hibernate-mapping>
<class
name="com.db.caaa.domain.Company"
table="COMPANY"
dynamic-update="false"
dynamic-insert="false"
>
<cache usage="nonstrict-read-write" />

<id
name="id" column="id" type="long" unsaved-value="-1" >
<generator class="native">
</generator>
</id>

<property
name="companyShortName" type="java.lang.String"
update="true" insert="true" access="property" >
<column
name="companyShortName"
length="20"
unique-key="CONAMESNAME"
not-null="true"
/>
</property>
<set
name="dbdcCDeliveryAddress"
table="DBDCDELIVERYADDRESS"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted">
<cache
usage="nonstrict-read-write"
/>

<key
column="company_fk"
>
</key>

<one-to-many
class="com.db.caaa.domain.DBDCDeliveryAddress"
/>
</set>

</hibernate-mapping>
DBDCDelivary Address mapping file

<hibernate-mapping>
<class
name="com.db.caaa.domain.DBDCDeliveryAddress"
table="DBDCDELIVERYADDRESS"
dynamic-update="false"
dynamic-insert="false" >
<cache usage="nonstrict-read-write" />

<id
name="id"
column="id"
type="long"
unsaved-value="-1"
>
<generator class="native">
</generator>
</id>

<property
name="receiverID"
type="java.lang.String"
update="true" insert="true" access="property">
<column
name="ReceiverId" not-null="false" unique="false"/>
</property>


<many-to-one
name="company"
class="com.db.caaa.domain.Company"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="property"
column="company_fk"
/>

</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

net.sf.hibernate.impl.SessionImpl - Could not synchronize database state with session
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.db.caaa.domain.DBDCDeliveryAddress
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2768)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2760)
at net.sf.hibernate.type.ObjectType.disassemble(ObjectType.java:206)
at net.sf.hibernate.impl.CacheEntry.disassemble(CacheEntry.java:38)
at net.sf.hibernate.impl.CacheEntry.<init>(CacheEntry.java:29)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:33)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.jca.JCASessionImpl.flush(JCASessionImpl.java:57)
at sun.reflect.GeneratedMethodAccessor300.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at weblogic.connector.common.internal.ConnectionWrapper.invoke(ConnectionWrapper.java:149)
at $Proxy10.flush(Unknown Source)
at com.csc.service.ServiceBase.saveBusinessObject(ServiceBase.java:67)
at com.db.caaa.approval.service.actions.ApprovalActionBase.saveOrUpdate(ApprovalActionBase.java:117)
at com.db.caaa.approval.service.actions.GenericUpdate.saveOrUpdate(GenericUpdate.java:171)
at com.db.caaa.approval.service.actions.CompanyUpdate.updateUpdate(CompanyUpdate.java:183)
at com.db.caaa.approval.service.actions.GenericUpdate.execute(GenericUpdate.java:73)
at com.db.caaa.service.ApprovalServiceBean.updateBusinessObject(ApprovalServiceBean.java:854)
at com.db.caaa.service.ApprovalServiceBean.update(ApprovalServiceBean.java:827)
at com.db.caaa.service.ApprovalServiceBean.save(ApprovalServiceBean.java:911)
at com.db.caaa.service.ApprovalService_xhvo3a_ELOImpl.save(ApprovalService_xhvo3a_ELOImpl.java:390)
at com.db.caaa.service.ApprovalAwareServiceBase.saveBusinessObject(ApprovalAwareServiceBase.java:88)
at com.db.caaa.service.CompanyService.saveCompany(CompanyService.java:100)
at com.db.caaa.service.CompanyService_6jnnay_ELOImpl.saveCompany(CompanyService_6jnnay_ELOImpl.java:46)

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


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.