Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi there this is newbiee questiom .
I have a link table (AgencyEmployee) and have a one to one association to (EmployeeContact). I was wondering how do i created a one to one mapping with EmployeeContact with a compoiste key defined in AgencyEmployee table. The reason I have created Employee Contact , is that not all employees in the AgencyEmployee table will be contacts.
I have got the agencyEmployee Composite key part working , but i dont know how to generate a one to one mapping based on a compoiste part in the EmployeeContact(agencyId,employeeId)
I create the same composite key in the EmployeeContact , but i have difficulty with the one-to many with constrained="true"
AgencyEmployee(1) ------------------(1) EmployeeContact
------------------- ---------------------
Agency_Id Agency_Id
Employee_Id Employee_Id
...
...
Are there any other alternatives ? Any suggestions.....
Thank you
Reeve
Hibernate version:3.0.rc
Mapping documents:
<hibernate-mapping package="orm">
<class name="AgencyEmployee" table="PD_AGENCY_EMPLOYEES">
<composite-id name="id" class="AgencyEmployee$Id" unsaved-value="any">
<key-property name="agencyId"
access="field"
column="AGY_LICENSE_ID"
length="10"/>
<key-property name="employeeId"
access="field"
column="EMP_ID"
length="10"/>
</composite-id>
<property name="dteCreated" column="DTE_CREATED" type="java.util.Date" not-null="true" />
<property name="idLogonCreated" column="ID_LOGON_CREATED" type="java.lang.String" not-null="true" />
<property name="dteLastUpdated" column="DTE_LAST_UPDATED" type="java.util.Date" not-null="true" />
<property name="idLogonLastUpdated" column="ID_LOGON_LAST_UPDATED" type="java.lang.String" not-null="true" />
##### What do i do hear ?
<many-to-one name="contacts" column="TITLE_ID" class="PdTitles" not-null="true" constrained="true"/>
#########
<many-to-one name="agency" column="AGY_LICENSE_ID" class="Agency" insert="false" update="false" not-null="true"/>
<many-to-one name="employee" column="EMP_ID" class="Employee" insert="false" update="false" not-null="true"/>
</class>
</hibernate-mapping>
[/code]