-->
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.  [ 2 posts ] 
Author Message
 Post subject: WHY "net.sf.hibernate.TransientObjectException" in
PostPosted: Fri Oct 15, 2004 4:18 am 
Beginner
Beginner

Joined: Thu Sep 04, 2003 2:52 am
Posts: 29
Hibernate version:
2.1.4
Mapping documents:

<class name="user.data.Right" table="tbl_user_right">
<id name="id" column="ID" unsaved-value="0">
<generator class="assigned">
</generator>
</id>
<property name="name" column="NAME"/>
<property name="desc" column="DESCRIPTION"/>
<property name="accessKey" column="ACCESS_KEY"/>
<many-to-one
name="father"
class="user.data.Right"
column="FATHER_ID"
cascade="none"
/>
</class>

Code between sessionFactory.openSession() and session.close():
Right rootRight = (Right)udao.queryObject(Right.class,1);
Right root = (Right)udao.queryObject(Right.class,0); // 0 is already in database
if(rootRight!=null) {
rootRight.setAccessKey("testkey");
rootRight.setFather(root);
udao.updateObject(rootRight);
log.debug("update ok.");
}
Full stack trace of any exception that occurs:
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.lianchuang.smartsecurer.user.data.Right
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2764)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2756)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.EntityType.isDirty(EntityType.java:139)
at net.sf.hibernate.type.TypeFactory.findDirty(TypeFactory.java:225)
at net.sf.hibernate.persister.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:267)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2504)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2454)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2256)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2235)
at DBUtil.insertObject(DBUtil.java:437)

Name and version of the database you are using:
sybase
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 15, 2004 4:20 am 
Beginner
Beginner

Joined: Thu Sep 04, 2003 2:52 am
Posts: 29
<b>code in hibernate updateObject method</b>
try
{
s = HibernateSessionFactory.openSession();
tx = s.beginTransaction();
s.update(bean);
s.flush();
tx.commit();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.