wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Mapping For CompositeID Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Mapping For CompositeID" Watch "Mapping For CompositeID" New topic
Author

Mapping For CompositeID

mona dubey
Greenhorn

Joined: May 27, 2005
Posts: 1
Hi Folks,

I am beginner for hibernate, I am not able to find proper mapping for a table containing composite ID. I am using Hibernate2 and the database is MySQL.

Here is the mapping I have done:


<composite-id>
<key-property name="year" type="java.lang.Long" column="year"/>
<key-many-to-one name="employee_id" class="com.tsystems.leavemanagement.hibernate.Employee" column="EMPLOYEE_ID"/>
<key-many-to-one name="leave_type_id" class="com.tsystems.leavemanagement.hibernate.LeaveType" column="LEAVE_TYPE_ID"/>
</composite-id>

<property
name="availed"
type="java.lang.Long"
column="AVAILED"
not-null="false"
length="11">
<meta attribute="field-description">
@hibernate.property
column="AVAILED"
length="11"
not-null="false"
</meta>
</property>
Help Urgently.
Thanks,
Mona
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Mapping For CompositeID
 
Similar Threads
Getting an error when trying to insert data
TransientObjectException while fetching data.
Query returs empty list but getting results in TOAD
Integrity constraint violation: for Hibernate Insert
Problem with Hibernate composite key mapping