-->
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.  [ 3 posts ] 
Author Message
 Post subject: HELP! many-to-one using composite-id
PostPosted: Fri Apr 30, 2004 11:02 am 
Newbie

Joined: Mon Mar 08, 2004 2:24 pm
Posts: 13
Location: Tampa, FL, USA
I have a CASE table that contains, among other things, 3 columns (branch, hearyear, hearperiod). These columns collectively make up the primary key of another table, HEARING_CALENDAR. I've created the associated objects (Case and HearingCalendar) and also created a HearingCalendarKey that contains the 3 attributes. This is listed as a composite-id in the HearingCalendar.

This seems like a typical many-to-one relationship, but I've having trouble with the mapping due to the composite id. I'm not sure what to put for the "column" attribute. I've seen the many-to-one examples and they all use a single column to specify the join attribute. Any idea on how I can do this? I am working with a legacy schema that I cannot change. Here are some specifics:

CASE
id (long)
:
branch (string)
hearyear (string)
hearperiod (long)
:

HEARING_CALENDAR
branch pk
hearyear pk
hearperiod pk
;


Code:
class Case {
   private HearingCalendar cal;

   /**
    * @hibernate.many-to-one  class="HearingCalendar"
    */
   HearingCalendar getCalendar() {
       return cal;
   }
}

class HearingCalendar {
   private HearingCalendarKey id;

   /**
    * @hibernate.id  type="HearingCalendarKey"
    */
   HearingCalendarKey getId() {
      return id;
   }
}

class HearingCalendarKey {
   private String branch;
   private String hearYear;
   private long hearPeriod;
   // associated getters/setters follow...
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 1:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Not sure this is possible with xdoclet
Code:
<composie-id ...>
  <key-property column="A" .../>
  <key-property column="B" .../>
</composite-id>


<many-to-one ...>
  <column name="A"/>
  <column name="B"/>
  <!-- same order as composite-id -->
</many-to-one>

_________________
Emmanuel


Top
 Profile  
 
 Post subject: HELP! many-to-one using composite-id via xdoclet
PostPosted: Fri Apr 30, 2004 1:58 pm 
Newbie

Joined: Mon Mar 08, 2004 2:24 pm
Posts: 13
Location: Tampa, FL, USA
Thanks. I'll start researching the xdoclet.... anyone already know the answer to this?

Thanks,
John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.