Women in Technology

Hear us Roar



Article:
  Hibernate Your Data
Subject:   Composite keys in one-to-many or many-to-many
Date:   2004-08-09 06:57:16
From:   jeffcaz
Great tutorial. My questions is, can you and if so how do you set up a relationship that uses a composite primary key. I know it is not the best way to design, but that is not the question.
Can you do something like this?


<set name="orderItems" table="order_items"
cascade="all" inverse="true">
<!-- <key column="order_id"/> -->
<composite-id>
<key-property name="orderId"/>
<key-property name="productId"/>
</composite-id>
<one-to-many class="test.hibernate.OrderItem"/>
</set>

Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • Composite keys in one-to-many or many-to-many
    2006-04-10 07:37:22  Venkatramana [View]

    Hi Jeffcaz,

    Did the above setup for the relationship worked for,because i am also facing the same problem.

    Hey can you let me know how did you solvd the problem or any one else can please help me out.

    Thanks in advance
    ramana