-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Typed Associations and delete-orphan?
PostPosted: Tue May 17, 2005 11:08 pm 
Newbie

Joined: Thu May 27, 2004 9:41 pm
Posts: 6
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.