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