aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate + One to many associate + Unidirectional Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate + One to many associate + Unidirectional" Watch "Hibernate + One to many associate + Unidirectional" New topic
Author

Hibernate + One to many associate + Unidirectional

mohsin daadesh
Greenhorn

Joined: Jan 04, 2009
Posts: 1

Reg file content:

<set
name="regAttachments"
cascade="all"
lazy="false"
inverse="true">
<key update="false">
<column name="I_REG" />
</key>

<one-to-many class="com.abc.xyz.commons.domain.RegistrationAttachment" />
</set>

RegAttachment content:
<hibernate-mapping>
<class name="com.abc.xys.commons.domain.RegistrationAttachment" table="REG_ATCHMNT">
<composite-id>
<key-many-to-one name="attachmentDetails"
class="com.abc.xyz.commons.domain.FileAttachment"
column="I_ATCH"
/>
<key-property name="registrationId"
column="I_REG"
type="integer"
/>


<!-- <key-many-to-one name="registration"
class="com.abc.xyz.commons.domain.Registration"
column="I_REG"
lazy="false"
/> -->

</composite-id>

<property name="attachmentType"
type="com.abc.xyz.commons.hibernate.types.AttachmentTypeType"
column="I_ATCH_TYP"
/>

</class>
</hibernate-mapping>

i want to implement unidirectional flow {not bi-irectional (commented code work fine for bidirectional)}

This code works fine for update but not for insert.
RegistrationAttachment regAtchmntObj = new RegistrationAttachment();
regAtchmntObj.setAttachmentDetails(fAttach);
regAtchmntObj.setAttachmentType(fAttach.getAttchmentType());
regAttachmentSet.add(regAtchmntObj);
i. I dont set registration id, that is auto+ in reg hbm file.

how do i make it work in unidirectional?

Thanks in anticipation.

friend
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate + One to many associate + Unidirectional