I must be missing something simple, but everything I tried, especially property-ref, did not work, and I don't want to resort to a formula.
I have 2 tables, Report and Image, that have no constraints whatsoever. But there is a 1-1 relationship: for each record in Report there exist only one in Image, and I wish to specify this <one-to-one> mapping.
Report's composite key is (e.g.) a,b,c,d, and Image's composite key is (e.g.) a,b,c. Field 'd' is, for practical purposes of my application, a constant. It is nonetheless part of the primary key.
This should be simple. Can someone explain what I'm overlooking? Can someone else point me to the tutorial or reference in which this concept is covered?
Thanks for your help
Here's a snippet of my report.hbm.xml and image.hbm.xml:
Code:
<!-- report.hbm.xml -->
<class name = "Report" <!-- ... --> >
<composite-id
mapped = "true"
class = "ReportCompositeKey">
<key-property name = "settleControlCode" type="string">
<column name = "SETTLE_CONTROL_NUMBER" sql-type = "varchar2"
length = "10" not-null = "true"/>
</key-property>
<key-property name = "invoiceCode" type="string">
<column name = "INVOICE"
sql-type = "varchar2"
length = "16"
not-null = "true" />
</key-property>
<key-property name = "salesId" type="java.lang.Long">
<column name = "SALES_ID"
sql-type = "number"
length = "10"
not-null = "true"/>
</key-property>
<key-property name = "xtekReportType" type="int" >
<column name = "XTEK_REPORT_TYPE"
sql-type = "number"
length = "5"
not-null = "true"/>
</key-property>
<key-property name = "xtekReportNumber" type="int">
<column name = "XTEK_REPORT_NUMBER"
sql-type = "number"
length = "5"
not-null = "true"/>
</key-property>
<key-property name = "xtekTimestamp" type="timestamp">
<column name = "XTEK_TIME_STAMP"
sql-type = "date"
length = "7"
not-null = "true"/>
</key-property>
<key-property name = "scanned" type="string">
<column name = "PAPER_SCANNED" sql-type = "char" length = "1"
not-null = "true"/>
</key-property>
</composite-id>
<!-- ... -->
</class>
<!-- image.hbm.xml -->
<class name = "Image" <!-- ... --> >
<composite-id
mapped = "true"
class = "ImageCompositeKey">
<key-property name = "settleControlCode" type="string">
<column name = "SETTLE_CONTROL_NUMBER" sql-type = "varchar2"
length = "16" not-null = "true"/>
</key-property>
<key-property name = "invoiceCode" type="string">
<column name = "DOCUMENT_NUMBER" sql-type = "varchar2" length = "16"
not-null = "true"/>
</key-property>
<key-property name = "salesId" type="java.lang.Long" >
<column name = "IDENTIFIER_CODE" sql-type = "number" length = "10"/>
</key-property>
<key-property name = "xtekReportType" type="int">
<column name = "REPORT_TYPE" sql-type = "number" length = "5"
not-null = "true"/>
</key-property>
<key-property name = "xtekReportNumber" type="int">
<column name = "REPORT_NUMBER" sql-type = "number" length = "10"/>
</key-property>
<key-property name = "xtekTimestamp" type="timestamp">
<column name = "TIME_STAMP" sql-type = "date" length = "7"/>
</key-property>
</composite-id>
<!-- ... -->
</class>