-->
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.  [ 3 posts ] 
Author Message
 Post subject: composite-element with cascade behaviour
PostPosted: Mon Oct 02, 2006 8:56 pm 
Beginner
Beginner

Joined: Thu Oct 06, 2005 8:14 pm
Posts: 23
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Hi

I have a relationship like so
Bank account has a contact
we have decided to map bank account as a composite-element
now the thing is when I delete bank account I want to be able to delete its contact as well
so in the compositeelement defn

<composite-element class="BankAccount" >
<many-to-one name="bankContact" column="ContactId" unique="true" class="Contact" cascade="all" />

</composite-element>

so if I make the bankaccount contact to null it does not cascade and delete the entry in the contact table...
Same goes with when I delete the bank account I want hte bank contact purged as well but I am able to delete the bank account but still have a entry for the bank contact
Any ideas
Regards
Subu


Top
 Profile  
 
 Post subject: Re: composite-element with cascade behaviour
PostPosted: Tue Oct 03, 2006 6:03 am 
Newbie

Joined: Mon Sep 13, 2004 9:44 am
Posts: 13
priyasubu wrote:
<composite-element class="BankAccount" >
<many-to-one name="bankContact" column="ContactId" unique="true" class="Contact" cascade="all" />

</composite-element>

so if I make the bankaccount contact to null it does not cascade and delete the entry in the contact table...


Cascades work on associations between entities. You did not delete the entity containing the back account, so there was no cascade to do. All you did was clear a many-to-one reference, just as if the bankContact had been a property of the outer entity.

It does not really make sense to set a composite element instance to null. If you use one-to-one instead on composite-element, then a cascade will work, but setting to null will still not make sense.

Chris.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 05, 2006 12:27 am 
Beginner
Beginner

Joined: Thu Oct 06, 2005 8:14 pm
Posts: 23
I tried using one to one in composite element I can't could you give me an example or something
Thanks
Subu


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

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.