Hi,
I have two tables in Oracle9i Database. One is parent and the other is child. The table schema is as follows.
Award
-------
award_id number(14) (P.K)
scheme_code varchar2(15)
student_id number(14)
school_code varchar2(10)
award_start_date date
award_end_date date
provisional_ind char(1)
version_no number(6)
AwardStatus
--------------
award_id number(14) (P.K)
status_code varchar2(10)
status_date date
version_no number(6)
Relationship is One-to-Many and Many-to-one. I mean One Award table can have Many records in AwardStatus table and Many records in the AwardStatus table can have one Award.
How can i specify the mapping for these two tables? Currently i am specifying the mapping as follows.
Award
--------
<class name="Award" table="award">
<id generator="sequence" unsaved-value="0">
<param name="award_seq">next_val</param>
</id>
<version name="versionNo" column="version_no"/>
<property name="schemeCode" column="scheme_code"/>
<proeprty name="studentId" column="student_id"/>
<property name="schoolCode" column="school_code"/>
<property name="awardStartDate" column="award_start_date" type="date"/>
<property name="awardEndDate" column="award_end_date" type="date"/>
<property name="provisionalInd" column="provisional_ind"/>
<Set name="awardStatus" inverse="true">
<key column="award_id"/>
<one-to-many class="AwardStatus"/>
</Set>
</class>
AwardStatus
--------------
<class name="AwardStatus" table="awardstatus">
<id generator="assigned"/>
<version name="versionNo" column="version_no"/>
<property name="statusCode" column="status_code"/>
<property name="statusDate" column="status_date" type="date"/>
</class>
I am not able to understand how to specify Many-To-One relationship in the AwardStatus mapping since both are sharing the same primary key.
According to the documentation, i know that two classes should have different primary keys, but i dont have rights to change the database schema at the moment. Can any one help me in understanding how to map the relation for the above situation.
Thanks.
Regards.
Lokesh.
|