Hibernate version:
3.0.3
I am using the Typed-associations feature in Hibernate... as outlined in Gavin's slides
For example:
Typed association
Code:
<class name="Identity" abstract="true">
<id name="id">…</id>
<property name="phoneNumber" length="20"/>
<one-to-one name="mailingAddress" cascade="all">
<formula>id</formula>
<formula>'MAILING'</formula>
</one-to-one>
<union-subclass name="Organization">
<property name="name"/>
<one-to-one name="businessAddress" cascade="all">
<formula>id</formula>
<formula>'BUSINESS'</formula>
</one-to-one>
</union-subclass>
. . .
Basically what typed associations provide is a way to represent a typical one-to-many (i.e. Person -> Address(s)) as a number of single point associations... with a type...
I know that one-to-many supports delete-orphan HOWEVER one-to-one association do NOT support a delete orphan strategy...
Anyway, my question is can a "typed single point association" support a delete-orphan...
Basically I have an Entity that has a number of Addresses, Phones, etc. (common case) and I have them mapped using typed associations.. however if a person needs to delete (say for instance) a Fax phone number or a Home phone number...
Parent side: (Person)
Code:
<one-to-one name="businessPhoneNumber" entity-name="BusinessPhone" property-ref="person" cascade="save-update,delete-orphan" fetch="select" />
<one-to-one name="cellPhoneNumber" entity-name="CellPhone" property-ref="person" cascade="save-update,delete-orphan" fetch="select"/>
. . .
Many side.. (Phone)
Code:
<composite-id>
<key-many-to-one name="person" column="PERSON_OID"/>
<key-property name="phoneTypeCode" column="PHONE_TYPE_CODE" type="int"/>
</composite-id>
<many-to-one name="person" column="PERSON_OID" insert="false" update="false"/>
Does a one-to-one typed association support delete-orphan or does this only work for mapping Address as a <set> and one-to-many?
I have tried a number of tweaks, delete, delete-orphan, etc.. Just wanted to confirm if this is something that is supported... ?
Technically its mapped as a one-to-one... however its still fundamentally a one to many... anyway since its mapped as 1:1.. do the one-to-one and no delete-orphan rule apply?
Cheers