-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Bug with <set/> and <element/>?
PostPosted: Mon Aug 01, 2005 10:58 am 
Beginner
Beginner

Joined: Tue Jul 12, 2005 10:27 am
Posts: 23
Why does the first set fail to delete, while the second set works just fine? Is this a bug or am I missing something in my mapping?


<!-- The set below fails to delete, BUT inserts just fine. -->
<set
name="names"
table="names_tbl"
lazy="false"
cascade="save-update,delete"
fetch="join"
batch-size="2"
>

<key>
<column name="I_APPL"/>
<column name="C_EVNT_TYP"/>
<column name="I_EVNT_PRDCT_SET"/>
</key>

<element type="string" column="M_PRDCT"/>

</set>

<!-- Both Inserts and Deletes work just fine. -->
<set
name="people"
table="people_tbl"
lazy="false"
cascade="save-update,delete"
access="field"
fetch="join"
batch-size="2"
inverse="true"
>

<key>
<column name="I_APPL"/>
<column name="C_EVNT_TYP"/>
<column name="I_EVNT_PRDCT_SET"/>
</key>

<one-to-many
class="People"
/>

</set>

How I delete the parent Object:

session.createQuery("delete from Parent where eventId = :eventId")
.setLong("eventId", eventId.longValue())
.executeUpdate();

_________________
- Richard Burton


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 5:37 am 
Beginner
Beginner

Joined: Wed May 04, 2005 5:17 am
Posts: 40
Is it because of the inverse setting? Try adding inverse="true" to your first set.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 9:19 am 
Beginner
Beginner

Joined: Tue Jul 12, 2005 10:27 am
Posts: 23
That's what I did first and it doesn't even save the values when setting inverse='true'

Which I thought was rather odd. Hence the reason you don't see it in my xml file.

_________________
- Richard Burton


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 9:24 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
yatesco wrote:
Is it because of the inverse setting? Try adding inverse="true" to your first set.


If you change your cascade on the sets to "all,delete-orphan" you can then delete the parent and both the names and people collections will be deleted for the given parent.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 9:29 am 
Beginner
Beginner

Joined: Wed May 04, 2005 5:17 am
Posts: 40
Yeah, sorry I meant inverse= false ;) And yes, you will also need delete-orphan to remove orphaned children.

Man, I gotta learn to read the post before answering ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 11:07 am 
Beginner
Beginner

Joined: Tue Jul 12, 2005 10:27 am
Posts: 23
I tried that and it doesn't work. I tried vairous combinations for cascade to understand what's going on.

It's still not removing the predicateNames. I'm using Hibernate 3.0.5 I see it generate the following SQL during the session factory "delete: delete from ISO04.RRV00313 where I_APPL=? and C_EVNT_TYP=? and I_EVNT_PRDCT_SET=? and M_PRDCT=?" but nothing for when I issue the HQL delete from parent where blah=x



<set
name="predicateNames"
table="RRV00313"
lazy="false"
cascade="all-delete-orphan"
fetch="join"
batch-size="2"
>

<key>
<column name="I_APPL"/>
<column name="C_EVNT_TYP"/>
<column name="I_EVNT_PRDCT_SET"/>
</key>

<element column="M_PRDCT" type="string"/>

</set>

<set
name="predicates"
table="RRV00317"
lazy="false"
cascade="save-update,delete"
access="field"
fetch="join"
batch-size="2"
inverse="true"
>

<key>
<column name="I_APPL"/>
<column name="C_EVNT_TYP"/>
<column name="I_EVNT_PRDCT_SET"/>
</key>

<one-to-many
class="Predicate"
/>

</set>

_________________
- Richard Burton


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.