-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate updates primary keys after inserting a collection
PostPosted: Wed Jun 13, 2007 2:57 am 
Newbie

Joined: Wed Jun 13, 2007 2:50 am
Posts: 2
Hi,

I have a class A that has a collection of instances of B.
I am mapping this relation with <bag> and cascade all.
When I persist A, it inserts all of B into the database.
However, inmediatly afterwards, I see in the console log several updates for the objects in the collection:
update B set id = 1 where id = 1
update B set id = 2 where id = 1
update B set id = 3 where id = 1

Thus throwing an update batch failed.
Why is Hibernate trying to update the PK after inserting?

Thanks,

Mariano.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 9:21 am 
Newbie

Joined: Fri May 18, 2007 4:38 pm
Posts: 3
Location: phoenix
Information give is not sufficient, but here is a pointer

when you use collection, hibernate generates updates internally something like pseudo updates. But, your batch update should still work and it you be able to insert in tables.

update B set id = 1 where id = 1

here the id=1(the first instance in the update query) should be the primary key(or a column) of the table A. check you mapping file for that.

the second instance of id=1 should be primary key of B.

Please check you mapping or post your mapping files.


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