-->
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: Unable to update - please help
PostPosted: Thu May 20, 2010 12:40 am 
Newbie

Joined: Thu May 13, 2010 12:21 pm
Posts: 7
Hi there,

Can someone please help resolve this error? I am trying to update in hibernate but transaction fails with the error "Illegal attempt to associate a collection with two open sessions". I am using Hibernate with Spring. I am using HibernateTemplate for the transactions. I have a simple form with Product information entry. In my controller, I read entries in form and then attempt to update. However, this fails with above mentioned error. In my controller, I have following code -

Code:
      
      Product product = this.productService.findByProductId(productId);
      Product commandProduct= (Product) command;     //command object
      product.setProductType(commandProduct.getProductType());
      product.setProductDescription(commandProduct.getProductDescription());
               
                this.productService.update(product);


As you can see above, commandProduct contains data from the form in GUI and based on the product id that is open, I load the product object, set values of some of the fields that were changed in GUI and then try to call update. The service method makes a simple call -

Code:
               getSession().update(product);


but above update statement fails with the error "Illegal attempt to associate a collection with two open sessions". When I try merge instead of update, then I don't get any errors but it does not update anything.

What am I doing wrong and how to correct this issue? Can any guru help?


Top
 Profile  
 
 Post subject: Re: Unable to update - please help
PostPosted: Thu May 20, 2010 8:27 am 
Newbie

Joined: Thu May 13, 2010 12:21 pm
Posts: 7
Any suggestions?


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.