-->
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: Problem with updating the set. Many to many relationship.
PostPosted: Sat Oct 30, 2010 5:49 am 
Newbie

Joined: Thu Oct 28, 2010 12:42 pm
Posts: 1
Hi.
I have many-to-many relationship.
Code:
class A {
Set<B> bs
}
class B {
}

<set name="bs" table="bs_tab" cascade = "save-update">
            <key column="a_id />
            <many-to-many column="b_id" class="B"/>
</set>
bs_tab is table(
a_id, b_id, primary key(a_id, b_id)
)

I use for A standard DAO. Problem is that when I first add some B to bs (b1) and then save A, and later I add another B (b2) and update A, b1 is deleted. I do those two operations on the same A instance. I save object calling session.saveOrUpdate(A instance). When you look at the generated sql commands it looks like hibernate is deleting all elements of bs from bs_tab before inserting new row into it. Does anyone know the solution?


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.