Hi guys,
Am using mysql 5.5 inno db with default settings,
hibernate 3 nad
spring 3Thanks in advance for any help
application is repeatedly getting following exception.
Lock wait timeout exceeded; try restarting transaction in hibernate I have two tables.
Say Tables A,B A---one-to-many relationship with B.
one row in Table A is associated with many rows in table B.
when i save records in table A, i have no issues. but for the next time onwards if trying to add new childs to exising parent record and meanwhile iam updating same parent record. then am getting following exception..
MY code is
Code:
Session session=null;
Boolean result = Boolean.FALSE;
try {
session = getHibernateTemplate().getSessionFactory().openSession();
for(EntryTaxPaymentDtlsDO paymnt: detailsDO.getEntryTaxPaymentDtls())
getHibernateTemplate().saveOrUpdate(paymnt); //Updates entry tax details and payment details
LOGGER.debug("EntryTaxDAOImpl :: updateEntryTaxDetails ::---performaing update operation");
String headerQry=updateHeaderForCreateEntryTax(detailsDO);
Query headerQuery=session.createQuery(headerQry);
if(!StringUtil.isEmpty(detailsDO.getCaseClose()) && detailsDO.getCaseClose().equalsIgnoreCase(EntryTaxConstants.CASECLOSE_YES)){
headerQuery.setDate(EntryTaxConstants.CLOSING_DATE_PARAM, DateFormatterUtil.getCurrentDate());
}
headerQuery.executeUpdate();
result =Boolean.TRUE;
} catch (Exception e) {
LOGGER.debug("EntryTaxDAOImpl::updateEntryTaxDetails::update========>"+e.getMessage());
e.printStackTrace();//TODO : need to remove later
throw new CGSystemException(e);
} finally{
if(session!=null)
session.close();
}
The complete stack trace
Code:
2012-06-12 18:36:50,728 [http-8080-2] DEBUG - --- SQL AST ---
\-[UPDATE] UpdateStatement: 'UPDATE' querySpaces (dtdc_f_entry_tax_detail)
+-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[taxDetails], fromElementByTableAlias=[entrytaxde0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'dtdc_f_entry_tax_detail' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=taxDetails,role=null,tableName=dtdc_f_entry_tax_detail,tableAlias=entrytaxde0_,origin=null,columns={,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO}}
+-[SET] SqlNode: 'SET'
| +-[EQ] BinaryLogicOperatorNode: '='
| | +-[DOT] DotNode: 'TOTAL_COLLECTION_AMT' {propertyName=totalAmtCollected,dereferenceType=ALL,propertyPath=totalAmtCollected,path=taxDetails.totalAmtCollected,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | | +-[ALIAS_REF] IdentNode: 'ENTRY_TAX_DTL_ID' {alias=taxDetails, className=com.dtdc.domain.entryTax.EntryTaxDetailsDO, tableAlias=entrytaxde0_}
| | | \-[IDENT] IdentNode: 'totalAmtCollected' {originalText=totalAmtCollected}
| | \-[NUM_DOUBLE] LiteralNode: '274.67'
| +-[EQ] BinaryLogicOperatorNode: '='
| | +-[DOT] DotNode: 'CASE_CLOSE' {propertyName=caseClose,dereferenceType=ALL,propertyPath=caseClose,path=taxDetails.caseClose,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | | +-[ALIAS_REF] IdentNode: 'ENTRY_TAX_DTL_ID' {alias=taxDetails, className=com.dtdc.domain.entryTax.EntryTaxDetailsDO, tableAlias=entrytaxde0_}
| | | \-[IDENT] IdentNode: 'caseClose' {originalText=caseClose}
| | \-[QUOTED_STRING] LiteralNode: ''YES''
| +-[EQ] BinaryLogicOperatorNode: '='
| | +-[DOT] DotNode: 'MODIFIED_OFFICE_ID ' {propertyName=officeId,dereferenceType=ALL,propertyPath=modifiedOfficeId.officeId,path=taxDetails.modifiedOfficeId.officeId,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | | +-[DOT] DotNode: 'MODIFIED_OFFICE_ID ' {propertyName=officeId,dereferenceType=0,propertyPath=modifiedOfficeId.officeId,path=taxDetails.modifiedOfficeId,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | | | +-[ALIAS_REF] IdentNode: 'ENTRY_TAX_DTL_ID' {alias=taxDetails, className=com.dtdc.domain.entryTax.EntryTaxDetailsDO, tableAlias=entrytaxde0_}
| | | | \-[IDENT] IdentNode: 'modifiedOfficeId' {originalText=modifiedOfficeId}
| | | \-[IDENT] IdentNode: 'officeId' {originalText=officeId}
| | \-[NUM_INT] LiteralNode: '10'
| +-[EQ] BinaryLogicOperatorNode: '='
| | +-[DOT] DotNode: 'USER_ID' {propertyName=userId,dereferenceType=ALL,propertyPath=userDo.userId,path=taxDetails.userDo.userId,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | | +-[DOT] DotNode: 'USER_ID' {propertyName=userId,dereferenceType=0,propertyPath=userDo.userId,path=taxDetails.userDo,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | | | +-[ALIAS_REF] IdentNode: 'ENTRY_TAX_DTL_ID' {alias=taxDetails, className=com.dtdc.domain.entryTax.EntryTaxDetailsDO, tableAlias=entrytaxde0_}
| | | | \-[IDENT] IdentNode: 'userDo' {originalText=userDo}
| | | \-[IDENT] IdentNode: 'userId' {originalText=userId}
| | \-[NUM_INT] LiteralNode: '17'
| \-[EQ] BinaryLogicOperatorNode: '='
| +-[DOT] DotNode: 'CLOSING_DATE' {propertyName=closingDate,dereferenceType=ALL,propertyPath=closingDate,path=taxDetails.closingDate,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| | +-[ALIAS_REF] IdentNode: 'ENTRY_TAX_DTL_ID' {alias=taxDetails, className=com.dtdc.domain.entryTax.EntryTaxDetailsDO, tableAlias=entrytaxde0_}
| | \-[IDENT] IdentNode: 'closingDate' {originalText=closingDate}
| \-[NAMED_PARAM] ParameterNode: '?' {name=closingDate, expectedType=org.hibernate.type.TimestampType@16ac126}
\-[WHERE] SqlNode: 'WHERE'
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'ENTRY_TAX_DTL_ID' {propertyName=entryTaxDtlsId,dereferenceType=ALL,propertyPath=entryTaxDtlsId,path=taxDetails.entryTaxDtlsId,tableAlias=entrytaxde0_,className=com.dtdc.domain.entryTax.EntryTaxDetailsDO,classAlias=taxDetails}
| +-[ALIAS_REF] IdentNode: 'ENTRY_TAX_DTL_ID' {alias=taxDetails, className=com.dtdc.domain.entryTax.EntryTaxDetailsDO, tableAlias=entrytaxde0_}
| \-[IDENT] IdentNode: 'entryTaxDtlsId' {originalText=entryTaxDtlsId}
\-[NUM_INT] LiteralNode: '14'
2012-06-12 18:36:50,728 [http-8080-2] DEBUG - throwQueryException() : no errors
2012-06-12 18:36:50,728 [http-8080-2] DEBUG - throwQueryException() : no errors
2012-06-12 18:36:50,743 [http-8080-2] DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-06-12 18:36:50,743 [http-8080-2] DEBUG - opening JDBC connection
2012-06-12 18:36:50,743 [http-8080-2] DEBUG - update dtdc_f_entry_tax_detail set TOTAL_COLLECTION_AMT=274.67, CASE_CLOSE='YES', MODIFIED_OFFICE_ID =10, USER_ID=17, CLOSING_DATE=? where ENTRY_TAX_DTL_ID=14
2012-06-12 18:37:41,775 [http-8080-2] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-06-12 18:37:41,775 [http-8080-2] DEBUG - could not execute update query [update dtdc_f_entry_tax_detail set TOTAL_COLLECTION_AMT=274.67, CASE_CLOSE='YES', MODIFIED_OFFICE_ID =10, USER_ID=17, CLOSING_DATE=? where ENTRY_TAX_DTL_ID=14]
java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:101)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:421)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1278)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)
at com.dtdc.ng.dao.entryTax.EntryTaxDAOImpl.updateEntryTaxDetails(EntryTaxDAOImpl.java:407)
at com.dtdc.ng.bs.entryTax.EntryTaxServiceImpl.saveEntryTaxDetails(EntryTaxServiceImpl.java:494)
at com.dtdc.ng.bs.entryTax.EntryTaxServiceImpl$$FastClassByCGLIB$$ead06d41.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.dtdc.ng.bs.entryTax.EntryTaxServiceImpl$$EnhancerByCGLIB$$7fd31144.saveEntryTaxDetails(<generated>)
at com.dtdc.ng.action.entryTax.EntryTaxDetailsAction.saveTaxDetails(EntryTaxDetailsAction.java:358)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at com.dtdc.ng.action.CTBSDispatchAction.execute(CTBSDispatchAction.java:69)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.capgemini.lbs.framework.filters.CTBSFilter.doFilter(CTBSFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
2012-06-12 18:37:41,791 [http-8080-2] WARN - SQL Error: 1205, SQLState: 41000
2012-06-12 18:37:41,791 [http-8080-2] ERROR - Lock wait timeout exceeded; try restarting transaction
2012-06-12 18:37:41,791 [http-8080-2] DEBUG - EntryTaxDAOImpl::updateEntryTaxDetails::update========>could not execute update query
org.hibernate.exception.GenericJDBCException: could not execute update query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:110)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:421)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1278)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)
at com.dtdc.ng.dao.entryTax.EntryTaxDAOImpl.updateEntryTaxDetails(EntryTaxDAOImpl.java:407)
at com.dtdc.ng.bs.entryTax.EntryTaxServiceImpl.saveEntryTaxDetails(EntryTaxServiceImpl.java:494)
at com.dtdc.ng.bs.entryTax.EntryTaxServiceImpl$$FastClassByCGLIB$$ead06d41.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.dtdc.ng.bs.entryTax.EntryTaxServiceImpl$$EnhancerByCGLIB$$7fd31144.saveEntryTaxDetails(<generated>)
at com.dtdc.ng.action.entryTax.EntryTaxDetailsAction.saveTaxDetails(EntryTaxDetailsAction.java:358)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at com.dtdc.ng.action.CTBSDispatchAction.execute(CTBSDispatchAction.java:69)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.capgemini.lbs.framework.filters.CTBSFilter.doFilter(CTBSFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:101)
... 45 more
2012-06-12 18:37:41,791 [http-8080-2] DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2012-06-12 18:37:41,791 [http-8080-2] DEBUG - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2012-06-12 18:37:41,791 [http-8080-2] ERROR - EntryTaxServiceImpl :: saveEntryTaxDetailsorg.hibernate.exception.GenericJDBCException: could not execute update query
com.capgemini.lbs.framework.exception.CGSystemException: org.hibernate.exception.GenericJDBCException: could not execute update query
at com.dtdc.ng.dao.entryTax.EntryTaxDAOImpl.updateEntryTaxDetails(EntryTaxDAOImpl.java:412)