Hi i am tring to examin behaviour of save and persist without any explicit transaction.My code is:-
public static void main(String[] args) { /*Employee emp = new Employee(); emp.setName("Pankaj1"); emp.setRole("CEO"); emp.setInsertTime(new Date());*/
//Get Session Session session = HibernateUtil.getSessionFactory().openSession(); //start transaction //session.beginTransaction(); //Save the Model object Employee emp = (Employee) session.get(Employee.class, 1); emp.setName("XYZ2"); session.save(emp); // session.persist(emp); //Commit transaction //session.getTransaction().commit(); System.out.println("Employee ID=" + emp.getId()); session.flush();
}
But i am getting the below exception,
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at com.sd.hibernate.main.HibernateMain.main(HibernateMain.java:32) Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1213) at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:912) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246) ... 6 more
SomeOne please explain....! i am using Hibernate 3.2.3 ga
|