• Post Reply Bookmark Topic Watch Topic
  • New Topic

BatchUpdateException when calling HibernateTemplate.update()  RSS feed

joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In my dao layer, I have two methods which load and update records in a user table. The user table is mapped one to one, and lazy loading is set to false. In these methods, I am using Spring's HibernateTemplate.

I am calling both these methods from a service layer to retrieve a user by username, modify it, then update the record. Basically, something like this:

First I did not execute these methods inside a transaction, and I saw the following stack trace:

11 Mar 2008 12:42:29,171 [http-8050-Processor25, ] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update


Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)

Once I put these calls inside a transaction, it works fine. What I would like to know is why I need the transaction for this update to work? I am using mysql 5

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!