I have a class that contains a component with 3 attributes. One of the attributes is used as part of a composite-id in a many-to-one relationship with another class. When trying to update the the class, I get the following exception:
Code:
net.sf.hibernate.MappingException: Repeated column in mapping for class org.arbfile.util.olf.model.Case should be mapped
with insert="false" update="false": branch
I know why I get this... branch is listed twice with update/insert both set to true. I tried to change update/insert to false on the branch in the DocketNumberKey, but received this exception:
Code:
net.sf.hibernate.MappingException: insert="false", update="false" not supported for properties of components: branch
If I change update/insert to false on the composite-id, then the hearyear and hearperiod columns are not updated with the class. I guess what need is the ability to specify update/insert at the column level within the composite-id. Is this possible? Is there another way to do what I'm wanting to do?
Unfortunately, I am tied to a legacy database so composite ids are everywhere. It is likely that branch or some other property will be used as part of several composite-ids in many-to-one relationships. The relevant mapping information is listed below.
Thanks in advance.
Code:
<class name="org.arbfile.util.olf.model.Case"
table="a_cca_case"
dynamic-update="false"
dynamic-insert="false"
>
<id name="docketNo" column="docket_no" type="string" >
<generator class="assigned">
</generator>
</id>
<component
name="docketNumberKey"
class="org.arbfile.util.olf.model.DocketNumberKey"
>
<property
name="program"
type="string"
update="true"
insert="true"
column="program"
/>
<property
name="branch"
type="string"
update="true"
insert="true"
column="branch"
/>
<property
name="sequenceNumber"
type="string"
update="true"
insert="true"
column="sequence_no"
/>
</component>
<many-to-one
name="hearingCalendar"
class="org.arbfile.util.olf.model.HearingCalendar"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column name="branch" />
<column name="hearyear" />
<column name="hearperiod" />
</many-to-one>
</class>
<class name="org.arbfile.util.olf.model.HearingCalendar"
table="a_calendar"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id>
<key-property name="branch" column="branch" type="string" />
<key-property name="hearYear" column="hearyear" type="string" />
<key-property name="hearPeriod" column="hearperiod" type="integer" />
</composite-id>
<property
name="noticeSent"
type="string"
update="true"
insert="true"
access="property"
column="noticesent"
/>
</class>