Hi all,
We are using Hibernate 2.1 with Oracle 9i. The ERD is virtually customer driven so we have little influence on legacy and third party design.
That said, Hibernate has proven to be very flexible. We are encountering the following problem though (contrived example):
We have the following two reference objects: PTA (account) and Organization:
<class
name="PTA"
table="IMIHS_PTA_T">
<composite-id name="comp_id" class="PTAPK">
<key-property
name="finCoaCd"
column="FIN_COA_CD"
/>
<key-property
name="project"
column="PROJECT"
/>
</composite-id>
bla bla
<!-- associations -->
<many-to-one name="organization" class="Organization" cascade="none" update="false" insert="false">
<column name="FIN_COA_CD" />
<column name="ORG_CD" />
</many-to-one>
</class>
<class
name="Organization"
table="IMIHS_ORG_T">
<composite-id name="comp_id" class="OrganizationPK">
<key-property
name="finCoaCd"
column="FIN_COA_CD"
/>
<key-property
name="orgCd"
column="ORG_CD"
/>
</composite-id>
</class>
We need the "update=false insert=false" as FIN_COA_CD is a repeated column, now this work fine in the user application where we don't want reference data to be modified from the business object perspective, however in the adminstrative interface we want to modify these, for instance insert a new PTA with relationship to Organization intact. Hence we need to discard "update=false insert=false" but we cannot because of the repeated columns. One possible solution to this problem is to have two sets of mapping files for PTA, the normal one as illiustrated above and another one where the Organization property is replace by a orgCd string property so we can atleast save the orgCd to the PTA table. However, this presents two problems: a) we would have two discrete files to maintain b) it might be impossible for Hibernate to have two mapping distinct mapping files referring to the same data (locking & integrity issues?) - we have not tried this.
Is there any other solution to this problem? If not, is the proposed solution a solution at all?
Thank you for all the help and support from Gavin and his team thus far!
Cheers,
Peter
|