• Post Reply Bookmark Topic Watch Topic
  • New Topic

Natural id spanning multiple persistent classes?  RSS feed

aravind yarram
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I've a situation where my business key is a combination of properties of two persistent entities. I am not sure how to use the "natural-id" element to group them. Following should be my business key

csaType + csaStartDate + csaEndDate + serialNumber (from Equipment.hbm.xml)

I appreciate your help. Thank you in advance!

Hibernate version: 3.x

Mapping documents:


<class name="Csa" table="CSA">
<id name="id" column="CSA_ID">
<generator class="native"/>
<property name="csaType" column="CSA_TYPE" type="string" not-null="true" length="2"/>
<property name="detailedCsaType" column="CSA_TYPE_DETAIL" type="string" not-null="true" length="20"/>
<property name="startingSmu" column="STARTING_SMU" type="double" not-null="true" precision="10" scale="2"/>
<property name="smuIndicator" column="SMU_INDICATOR" type="string" not-null="true" length="2"/>
<property name="equipmentDeliveryDate" column="EQUIP_DELIVERY_DATE" type="date" not-null="true" />
<property name="csaStartDate" column="CSA_START_DATE" type="date" not-null="true" />
<property name="csaEndDate" column="CSA_END_DATE" type="date" not-null="true" />
<component name="csaSourceInfo" class="CsaSource">
<property name="dealerCode" column="DEALER_CODE" type="string" not-null="true" length="6"/>
<property name="regionCode" column="REGION_CODE" type="string" not-null="true" length="5"/>
<component name="csaAuditInfo" class="AuditInfo">
<property name="enteredDate" column="ENTERED_DATE" type="date" not-null="true" />
<property name="committer" column="COMMITTER" type="string" not-null="true" length="10"/>
<property name="modifiedDate" column="MODIFIED_DATE" type="date" not-null="true" />
<many-to-one name="equipment" class="Equipment" column="FK_EQUIP_ID" cascade="all" unique="true"/>


<class name="Equipment" table="EQUIPMENT">
<id name="id" column="EQUIP_ID">
<generator class="native" />
<property name="equipmentType" column="EQUIP_TYPE" type="string" not-null="true" length="2"/>
<property name="serialNumber" column="SERIAL_NUM" type="string" not-null="true" length="20"/>
<property name="model" column="MODEL" type="string" not-null="true" length="10"/>
<property name="industryCode" column="INDUSTRY_CODE" type="string" not-null="true" length="2"/>
<property name="mode" column="MODES" type="string" not-null="true" length="1"/>
<one-to-one name="owningCsa" class="Csa" property-ref="equipment"/>

Name and version of the database you are using racle 10g
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!