i got problem to persist parent and child. below is my mapping file and error message i got.
Mapping documents:
<hibernate-mapping>
<class name="scratch.Child" table="child" dynamic-update="false"
dynamic-insert="false" >
<id name="id" column="ID" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<version name="version" type="integer" column="VERSION" access="property" unsaved-value="null" />
<many-to-one name="receivePack" class="scratch.Parent" cascade="none" outer-join="auto" update="true" insert="true" access="property" column="RECEIVE_PACK" not-null="true" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="scratch.Parent" table="parent" dynamic-update="false"
dynamic-insert="false" >
<id name="id" column="id" type="java.lang.Integer">
<generator class="assigned"></generator>
</id>
<version name="version" type="integer" column="version" access="property" unsaved-value="null"/>
<list name="packItems" lazy="false" inverse="true"
cascade="all-delete-orphan">
<key column="RECEIVE_PACK">
</key>
<index column="NO" type="integer"/>
<one-to-many class="scratch.Child" />
</list>
</class>
</hibernate-mapping>
Session Code
ses = ThreadLocalSession.currentSession();
ses.save(parent);
ses.flush();
Error Message:
2004-11-05 09:25:42,946 DEBUG [net.sf.hibernate.impl.SessionImpl] saving [scratch.Parent#04-114]
2004-11-05 09:25:42,946 DEBUG [net.sf.hibernate.engine.Cascades] processing cascades for: scratch.Parent
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.engine.Cascades] done processing cascades for: scratch.Parent
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.engine.Cascades] processing cascades for: scratch.Parent
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.engine.Cascades] cascading to collection: scratch.Child
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.engine.Cascades] cascading to saveOrUpdate()
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.engine.Cascades] version unsaved-value strategy NULL
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.impl.SessionImpl] saveOrUpdate() unsaved instance
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.impl.SessionImpl] saving [scratch.Child#<null>]
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.engine.Versioning] Seeding: 0
2004-11-05 09:25:42,962 DEBUG [net.sf.hibernate.impl.SessionImpl] closing session
|