-->
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.  [ 2 posts ] 
Author Message
 Post subject: This mapping problem is defeating me
PostPosted: Wed Aug 10, 2005 12:54 pm 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
I'm trying to map a structure like this:

We have 3 entities, Foo, Bar and Baz.

Image

Code:
<class name=Foo>
  <many-to-one name=bar class=Bar column=BAR_ID unique=true />
</class>

<class name=Bar>
  <one-to-one name=foo class=Foo property-ref=bar />
  <many-to-one name=baz class=Baz column=BAZ_ID />
</class>

<class name=Baz>
  <set name=bars>
    <key column=BAZ_ID />
    <one-to-many class=Bar />
  </set>

  <set name=foos>
    ????? PROBLEM ?????
  </set>
</class>


I'm trying to establish another <set> property in Baz which contains a collection of Foos, but I have no idea how how to map this. Any help?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 1:52 pm 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
I was able to accomplish my goal using a combination of <subselect> and <composite-element>. Here is an example (I can't be bothered to foo-bar-bazify it)

Code:
      <set name="itemAnnotations" table="ITEM_ANNOTATION">
         <subselect>
            (select r.RELEASE_ID,
               a.ITEM_ANNOTATION_ID, a.ITEM_ID, a.ITEM_ANNOTATION_TITLE,
               a.ISSUE_DESC, a.STATUS_DESC, a.CLOSED_FLAG
            from ITEM_ANNOTATION a
               inner join ITEM i on i.ITEM_ID = a.ITEM_ID
               inner join RELEASE r on r.RELEASE_ID = i.RELEASE_ID)
         </subselect>
         
         <key column="RELEASE_ID"/>

         <composite-element class="ItemAnnotationImpl">
            <many-to-one name="item" class="ItemImpl" column="ITEM_ID" unique="true" not-null="true"/>
            <property name="title" column="ITEM_ANNOTATION_TITLE" not-null="true"/>
            <property name="issueDescription" column="ISSUE_DESC" not-null="true"/>
            <property name="statusDescription" column="STATUS_DESC" not-null="true"/>
            <property name="closed" column="CLOSED_FLAG" not-null="true"/>      
         </composite-element>
      </set>


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

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.