-->
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.  [ 5 posts ] 
Author Message
 Post subject: org.hibernate.exception.LockAcquisitionException
PostPosted: Mon Mar 06, 2006 2:41 am 
Newbie

Joined: Wed Feb 22, 2006 2:15 am
Posts: 10
String products[] = deletedUser.split(",");

for (int i=0; i<products.length; i++)
{
UserImpl product = (UserImpl) sess.load(UserImpl.class, products[i]);
sess.delete (product);
sess.flush();
}

When I try to delete user I am getting the following exception :


org.hibernate.exception.LockAcquisitionException: could not lock: [com.uniken.adsalesentities.UserImpl#SE228]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.BasicEntityPersister.lock(BasicEntityPersister.java:1003)
at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:78)
at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:62)
at org.hibernate.impl.SessionImpl.lock(SessionImpl.java:508)
at org.apache.jsp.adsales.masterdatamgmt.user_jsp._jspService(org.apache.jsp.adsales.masterdatamgmt.user_jsp:218)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1366)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:952)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1722)
at org.hibernate.persister.entity.BasicEntityPersister.lock(BasicEntityPersister.java:987)



The user mapping file is as follows :


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
auto-import="false"
>
<class
name="com.uniken.adsalesentities.UserImpl"
table="User"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>

<id
name="userId"
column="userId"
type="java.lang.String"
unsaved-value="null"
>
<generator class="assigned">
</generator>
</id>

<property
name="userName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="userName"
/>

<property
name="password"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="password"
/>


<many-to-one
name="userRole"
class="com.uniken.adsalesentities.UserRoleImpl"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="userRoleId"
/>

<many-to-one
name="country"
class="com.uniken.adsalesentities.CountryImpl"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="countryId"
/>

<many-to-one
name="lineManager"
class="com.uniken.adsalesentities.UserImpl"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="lineManagerId"
/>

<property
name="emailId"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="emailId"
/>

<property
name="mobileNumber"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="mobileNumber"
/>

</class>

</hibernate-mapping>

Please help me solve this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 5:41 am 
Newbie

Joined: Wed Feb 22, 2006 2:15 am
Posts: 10
Thanks it is solved


Top
 Profile  
 
 Post subject: Re: org.hibernate.exception.LockAcquisitionException
PostPosted: Wed Feb 28, 2007 11:28 am 
Newbie

Joined: Tue Feb 13, 2007 11:54 am
Posts: 2
So what is the solution? I've got the same problem:

java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)

Session is opened, transaction is started, ..., then transaction is closed, then session is closed.
Can't understand what causes deadlock. I'am working in multythred environment - could it cause the problem ? If yes, then how can it be fixed?

Thanks for help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 28, 2007 7:47 pm 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
Release the lock. There is no other way.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 12:04 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi kzinoviev,

If some body was debugging then at same time other wants to try to access lock will not able to get it. Second major things could be Not proper handling of transaction

_________________
Dharmendra Pandey


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

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.