• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with saveorupdate method in hibernate 3.2

 
ravi pamuru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im using struts2.0, hibernate3.2 and java 1.5 in my application. Actual problem is im fetching the data from oracleDB using date field. The record which i was fetched is set to the bean in the jsp page itself. After modifying the data in the form and clicks on submit button it creates a new bean and sets the data in the new bean.Instead of update in hibernate query it is inserting the record and displays an error message " batch update exception". id is a primary key in the table.If i use hidden field for id in the jsp it displays "id already exists exception".

if anyone knows the solution please tell me the solution. thanks in advance.
Regards,
Ravi
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you are sending the data to the client, it becomes a detached object, and you will want to merge the detached object into the Session first.

http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#merge(java.lang.Object)

Mark
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!