All the examples on this site, and in the manual just say to add those 2 lines, but to where!?!
I have a very simple example, just two classes, BOOK and BARCODE. I want them to have the same primary key. Here's my mappings:
<hibernate-mapping>
<class
name="Barcode"
table="tbl_BARCODE"
dynamic-update="false"
dynamic-insert="false">
<id name="id"
column="ID"
type="java.lang.Long"
unsaved-value="-1">
<generator class="foreign">
<param name="property">Barcode</param>
</generator>
</id>
<one-to-one
name="id"
class="Book"
cascade="none"
outer-join="auto"
constrained="false"/>
<property
name="barcode_value"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="BARCODE_VALUE"/>
</class>
</hibernate-mapping>
-----------------------------------------------------
<hibernate-mapping>
<class
name="Book"
table="tbl_BOOK"
dynamic-update="false"
dynamic-insert="false">
<id name="id"
column="ID"
type="java.lang.Long"
unsaved-value="-1">
<generator class="native">
</generator>
</id>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="NAME"/>
<one-to-one
name="bc"
class="Barcode"
cascade="all"
outer-join="auto"
constrained="false"/>
</class>
</hibernate-mapping>
Do I need to add a reference from BOOK to BARCODE , and vice versa?
Thanks.
|