Hi
I have two tables; Person and Address (a Person has only one Address and it owns it; Address does not know about Person). Person and Address share the same primary key.
When I map Person and Address as follows:
Code:
<hibernate-mapping>
<class name="Person" table="PERSON">
<id name="id" type="long" column="PERSON_SEQ_NO">
<generator class="native" />
</id>
<one-to-one name="address" class="Address" cascade="all" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="Address" table="ADDRESS">
<id name="id" type="long" column="ADDRESS_SEQ_NO">
<generator class="native" />
</id>
<property name="line1" column="LINE_1"/>
<property name="postcode" column="POSTCODE"/>
</class>
</hibernate-mapping>
then I get a Person object with the right Address object set on them.
However, if I have a WibblePerson who extends Person and who should have a WibbleAddress (Person no longer has an Address), this mapping does not produce a one-to-one association:
Code:
<hibernate-mapping>
<joined-subclass name="WibblePerson" extends="Person" table="WIBBLEPERSON">
<key column="WIBBLE_PERSON_SEQ_NO"/>
<one-to-one name="address" class="WibbleAddress" cascade="all" />
</joined-subclass>
</hibernate-mapping>
<hibernate-mapping>
<class name="WibbleAddress" table="WIBBLEADDRESS">
<id name="id" type="long" column="WIBBLE_ADDRESS_SEQ_NO">
<generator class="native" />
</id>
<property name="line1" column="LINE_1"/>
<property name="postcode" column="POSTCODE"/>
</class>
</hibernate-mapping>
Does anyone know why this is not possible?
thanks, Baljeet.