-->
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.  [ 3 posts ] 
Author Message
 Post subject: Deadlock found when trying to get lock. pls help me !
PostPosted: Wed Dec 07, 2005 3:46 am 
Newbie

Joined: Thu Dec 01, 2005 3:43 am
Posts: 11
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.1.7

Hi,

i have one to many relation with employee to attendance. one employee
can have many attendance time in a office.
and my database is mysql where checkin and checkout is datetime type.

when i going to update checkout field of a particular attendance object
then there is exception occurs:

which is given below:
Hibernate: update attendance set purpose=?, attendance_flag=?, checkout=?, remarks=?, checkin=?, employee_oid=? where oid=?
- SQL Error: 1205, SQLState: 41000
- Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; Try restarting transaction"
- SQL Error: 1205, SQLState: 41000
- Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; Try restarting transaction"
- Could not execute JDBC batch update
java.sql.BatchUpdateException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; Try restarting transaction"
---------------------------------------------------------------
i have the following hbm file below:

<class name="Employee" table="employee">
<id
column="oid"
name="Oid"
type="string"
>
<generator class="com.simec.oms.util.IDGenerator" />
</id>
<set name="attendances" cascade="all" inverse="true" lazy="true">
<key column="employee_oid"/>
<one-to-many class="com.simec.oms.common.data.Attendance"/>
</set>
***************************************
<class
name="Attendance"
table="attendance"
>
<id
name="Oid"
type="string"
column="oid"
>
<generator class="com.simec.oms.util.IDGenerator" />
</id>
<property
name="Checkout"
column="checkout"
type="java.sql.Timestamp"
not-null="false"
length="19"
/>
<property
name="Checkin"
column="checkin"
type="java.sql.Timestamp"
not-null="false"
length="19"
/>
<many-to-one name="emp" class="com.simec.oms.common.data.Employee" column="employee_oid"/>
***************************************

the code below i used to update checkout field of an attendance which has oid=1133979746133.
######################################
session = getSession();
Attendance attendance=(Attendance) session.load(Attendance.class,"1133979746133");


Long l=new Long(System.currentTimeMillis());

Timestamp t=new Timestamp(l.longValue());



attendance.setCheckout(t);



session.flush();
closeSession();
######################################

my attendance table contains the row below:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
oid
1133979746133
chekcin
2005-12-07 13:22:26
checkout
NULL
remark
NULL
purpose
NULL
atttendance_flag
NULL
employee_oid
1132089217508
^^^^^^^^^^^^^^^^^^^^^^^^^^^

pls help me to solve this problem. or how can i update any field of a many side object in a one to many relation ship?

thank you

Chinmoy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 5:09 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
commit transaction before to close session.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 11, 2005 11:17 pm 
Newbie

Joined: Thu Dec 01, 2005 3:43 am
Posts: 11
thanks for that solution


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.