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...
}