Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Natural id spanning multiple persistent classes?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

Csa.hbm.xml

<class name="Csa" table="CSA">
<id name="id" column="CSA_ID">
<generator class="native"/>
</id>
<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>
<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" />
</component>
<many-to-one name="equipment" class="Equipment" column="FK_EQUIP_ID" cascade="all" unique="true"/>
</class>

Equipment.hbl.xml

<class name="Equipment" table="EQUIPMENT">
<id name="id" column="EQUIP_ID">
<generator class="native" />
</id>
<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"/>
</class>

Name and version of the database you are using racle 10g
reply
    Bookmark Topic Watch Topic
  • New Topic