-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problems with updating the db
PostPosted: Mon Jun 22, 2009 6:59 am 
Newbie

Joined: Wed Feb 25, 2009 2:50 am
Posts: 3
Hi,

I have a problem when using the saveOrUpdate method (through the HibernateTemplate in Spring). I try to explain the problem without attaching any code to begin with since I think that I'm doing some fundamental error.

A mapped object "Entity" has a relation to another mapped object "EntitySector". This is mapped as a "bag" in the mapping files and implemented as a List in the java code. The relationship is configured with "cascade=all" and "lazy=false".

The first call to saveOrUpdate (with an Entity not stored in the database yet) works fine and entries is made both in the Entiy table as well in the EntitySector table. But a subsequent call to the method fails. This is due to that Hibernate tries to update the EntitySector table with a null value to the EntityId property/column. This is done even though all properties in Entity and EntitySector do have valid values in my call to the method.

As said before, I know that I must do something fundamentally wrong but can't figure out what it is. Does anyone have any ideas?

//Magnus


Top
 Profile  
 
 Post subject: Re: Problems with updating the db
PostPosted: Mon Jun 22, 2009 7:57 am 
Newbie

Joined: Fri Dec 14, 2007 8:44 am
Posts: 10
use updatewithevit() method.


Top
 Profile  
 
 Post subject: Re: Problems with updating the db
PostPosted: Tue Jun 23, 2009 2:12 am 
Newbie

Joined: Wed Feb 25, 2009 2:50 am
Posts: 3
ceezane wrote:
use updatewithevit() method.


And where do I find this method?

//Magnus


Top
 Profile  
 
 Post subject: Re: Problems with updating the db
PostPosted: Mon Jul 27, 2009 6:39 am 
Newbie

Joined: Fri Dec 14, 2007 8:44 am
Posts: 10
ok,

first do update(entity_obj),
then do evit(entity_obj),


hope it will help you !!


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