-->
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: Composite Key Class with Collection Mapping Example Request
PostPosted: Sun Jun 12, 2005 3:44 pm 
Beginner
Beginner

Joined: Fri May 13, 2005 11:48 am
Posts: 32
Based on reading http://www.hibernate.org/hib_docs/refer ... nents.html Section 7.4 I am confused about how to map a Class with a composite key that then has a collection of children. The document seems to say that you have to pass the composite key some how but I can't deduce it.

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo" assembly="MyBiz" namespace="MyBiz.Model">
  <class name="Industry" table="SSC_Industry">
    <composite-id name="Id" class="CompositeKey" unsaved-value="any" access="property">
       <key-property name="Key" type="String" column="Id"/>
       <key-many-to-one name="Language" class="Language" column="Language"/>
    </composite-id>
   
    <property name="Name" column="Name" type="String" />
   
    <bag name="Sectors" inverse="true" lazy="false" cascade="all">
      <key column="ParentId" />
      <one-to-many class="Sector" />
      <!-- Problem Area -->
    </bag>
  </class>
 
  <class name="Sector" table="SSC_Sector">
    <composite-id name="Id" class="CompositeKey" unsaved-value="any" access="property">
       <key-property name="Key" type="String" column="Id"/>
       <key-many-to-one name="Language" class="Language" column="Language"/>
    </composite-id>
    <property name="Name" column="Name" type="String" />
   
    <many-to-one name="Industry" class="Industry" not-null="true">
        <column name="ParentId"/>
        <column name="Language"/>
    </many-to-one>
  </class>
</hibernate-mapping>


Problem Area
What should be here?
Code:
    <bag name="Sectors" inverse="true" lazy="false" cascade="all">
      <key>
          <column name="ParentId"/>
          <column name="Language"/>
      </key>
      <one-to-many class="Sector" />
    </bag>


Thanks!


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.