Hi friends,
My application throwing this exception when we try to delete record from table i am using many-to-one relationship.
==================Exception=======================
Hibernate: select employee0_.id as id0_0_, employee0_.name as name0_0_, employee0_.age as age0_0_, employee0_.empid as empid0_0_ from Employee employee0_ where employee0_.id=?
Hibernate: delete from Employee where id=?
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
==================My code is as:-====================
Session session = Hiberutil.getCurrentSession();
Transaction t = session.beginTransaction();
Employee p = (Employee)session.load(Employee.class,RecordID);
System.out.println("ID==="+p.getId());
session.delete(p);
session.flush();
t.commit();
session.close();\
====================HBM FILE====================
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="first.Employee" table="Employee">
<id name="id" type="int">
<generator class="increment"/>
</id>
<property name="name" type="string"/>
<property name="age" type="int"/>
<property name="empid" type="string"/>
</class>
</hibernate-mapping>
===================HBM FILE=====================
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="first.EmployeeTask" table="EmployeeTask">
<id name="id" type="int">
<generator class="increment"/>
</id>
<property name="project" type="string"/>
<property name="device" type="string"/>
<property name="deadline" type="string"/>
<property name="status" type="string"/>
<many-to-one name="parent_id" class="first.Employee" cascade="save-update,delete" />
</class>
</hibernate-mapping>
can any tell me what i missing
Thanks in adv.
|