-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate + Spring can't delete, update, save
PostPosted: Thu May 21, 2009 10:14 am 
Newbie

Joined: Thu May 21, 2009 9:59 am
Posts: 1
I am Using Spring 2.5, Hibernate 3.2 and MySQL 5.1.32 (included in wamp 2.0)

applicationContext.xml
Code:
<bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation"
         value="classpath:hibernate.cfg.xml">
      </property>
   </bean>
   
   <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory">
         <ref bean="sessionFactory"/>
      </property>
    </bean>
   
   <bean id="UsersDAO" class="com.smsapp.hibernate.UsersDAO">
      <property name="sessionFactory">
         <ref bean="sessionFactory" />
      </property>
   </bean>
<bean id="LocationDAO" class="com.smsapp.hibernate.LocationDAO">
      <property name="sessionFactory">
         <ref bean="sessionFactory" />
      </property>
   </bean>


Users.java, UsersDAO.java, Location.java and LocationDAO.java are generated with MyEclipse 7.0

I tried a simple delete with this code in LocationDAO.java

Code:
public static void main(String[] args) {
   ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        LocationDAO loc = LocationDAO.getFromApplicationContext(ctx);
        System.out.println(loc.findById(3).getLocationName());
   loc.delete(loc.findById(3));
   }


System.out.println returns the location name but I get this error:

Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL [delete from oms.location where id=?]; SQL state [41000]; error code [1205]; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:124)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:842)
at com.smsapp.hibernate.LocationDAO.removeRecord(LocationDAO.java:154)
at com.smsapp.hibernate.LocationDAO.main(LocationDAO.java:161)
Caused by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
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 org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:420)
... 4 more

Only save(), delete(), and update(), doesn't work. It's very annoying, everyone just keeps telling me to restart the transaction, but that doesn't seems to be the problem. Anyone experienced the same problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.