hello,
I am trying to delete multiple rows of data using the session.delete() method, but I'm getting an exception with the ff msg:
Hibernate: delete from tb_dept_accounts where deptId=?
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.
java:65)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2340)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
there are several occurrences of deptId in the tb_dept_accounts table. The deptIds were deleted from the table but I also get this msg. When there was only one deptId, the delete transaction got no error message. Why is this so and what can I do to workaround this problem?
Im using Hibernate 2
mapping is
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="maintenance.model.DeptAccnt" table="tb_dept_accounts">
<id name="departmentCode" column="deptId" type="string" unsaved-value="none">
<generator class="assigned"/>
</id>
<property name="accntId" column="accntId"/>
</class>
</hibernate-mapping>
Im calling the delete method from Action class
public String deleteDeptAccnts(){
try{
deptAccntsDAO.deleteAccnts(getDeptAccnt());
// where getDeptAccnt is the object
}catch(Exception ex){
return ERROR;
}
return SUCCESS;
}
from the deptAccntsDAO class
public void deleteAccnts(DeptAccnt deptAccnt) throws Exception{
begin();
session.delete(deptAccnt);
commit();
}
thanks
|