Beginner |
|
Joined: Sun Nov 16, 2003 9:30 am Posts: 20
|
Hi all,
I am trying to save a new object as follow :
Idea idea = new Idea();
idea.setXXX();
idea.setAttachments(new ArrayList());
Attachment a1 = new Attachment();
a1.setXXX();
idea.getAttachments().add(new Attachment());
mySession.save(idea)
only idea is saved by a1 is not saved. Is this the expected behaviour or a1 should be saved automatically ?
and idea to a1 is mono-directional.
Thanks.
Perseus
Here is my post.hbm.xml
============================================
<hibernate-mapping package="com.beez.idea.model">
<class name="Post" table="T_POST">
<id name="id" type="long">
<generator class="identity"/>
</id>
<property name="Subject" column="Subject" type="string"/>
<joined-subclass name="Idea" table="T_IDEA">
<key column="POST_ID"/>
<property name="Price" column="PRICE" type="double" not-null="true"/>
<bag name="Attachments" lazy="true">
<key column="ATTACHED_TO_ID"/>
<one-to-many class="com.beez.idea.model.Attachment"/>
</bag>
</joined-subclass>
<joined-subclass name="Attachment" table="T_ATTACHMENT">
<key column="POST_ID"/>
<property name="FileName" column="FILE_NAME" type="string" not-null="true"/>
</joined-subclass>
</class>
</hibernate-mapping>
|
|