• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

while updating the data iam getting error

 
vijay akni kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to update the data using spring--hibernate. but iam getting error saying

[2008-22-26 03:22]DEBUG[http-80-Processor24](NewPooledConnection.java:363) - com.mchange.v2.c3p0.impl.NewPooledConnection@10da1d8 handling a throwable.
java.sql.BatchUpdateException: Duplicate entry 'ff8080811b775f70011b776d270b0001' for key 2
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)



[2008-22-26 03:22]DEBUG[http-80-Processor24](SqlUtils.java:85) - Attempted to convert SQLException to SQLException. Leaving it alone. [SQLState: 23000; errorCode: 1062]
java.sql.BatchUpdateException: Duplicate entry 'ff8080811b775f70011b776d270b0001' for key 2
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)



[2008-22-26 03:22]DEBUG[http-80-Processor24](DefaultConnectionTester.java:126) - Testing a Connection in response to an Exception:
java.sql.BatchUpdateException: Duplicate entry 'ff8080811b775f70011b776d270b0001' for key 2
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)




[2008-22-26 03:22]DEBUG[http-80-Processor24](JDBCExceptionReporter.java:63) - Could not execute JDBC batch update [insert into TDesiredPosition (authorizedToWork, employmentStatus, roles, jobTitle, desiredJobType, desiredLocation, relocate, desiredSalary_lacs, desiredSalary_thousands, usWorkStatus, user_id, notice_period, desiredId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
java.sql.BatchUpdateException: Duplicate entry 'ff8080811b775f70011b776d270b0001' for key 2
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll keep this here, but it doesn't look like a Spring error. It looks like a JDBC error, in that in your batch, you have two records that have the same key value.

java.sql.BatchUpdateException: Duplicate entry 'ff8080811b775f70011b776d270b0001' for key 2

Mark
 
vijay akni kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that the existing record is same but i want to update the same record with particular fields that got changed. how to write the xdoclets in hibernate for updating the existing record.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vijay akni kumar:
I know that the existing record is same but i want to update the same record with particular fields that got changed. how to write the xdoclets in hibernate for updating the existing record.


Don't know about using xdoclet, but this is a Hibernate question, which we will move this thread to that forum.

Hibernate knows when to do an update or insert based on if the object has its id field set. If it isn't set it does an insert. So your update object you are passing does not have an id set in it.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic