-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: how to create a 1-to-1 mapping with a compoiste key ?
PostPosted: Wed Mar 16, 2005 10:51 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 10:26 am
Posts: 22
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.