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:
|
|