hi
I have some trouble with a simple delete of a row in a Mysql-Database.
The Hibernate-Exception is:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
or in log files:
Code:
Hibernate: delete from termine_user where UID=?
- Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
....
My Code to delete a row ... :
Code:
private String deleteGlobalTermin(termine termine){
String ret = "";
try {
System.out.println("deleting termine"+termine.getTERMIN_ID());
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.delete(termine);
session.flush();
session.clear();
tx.commit();
HibernateUtil.closeSession();
ret = "Success - ";
} catch( HibernateException ex ) {
ret = "error1: "+ex;
} catch ( Exception ex2 ){
ret = "error2: "+ex2;
}
return ret;
}
and it is really just a single row .. no collection, no set, no bag here is the file termin.hbm.xml:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="stz.xmlshop.Hibernate.Beans.termine.termine" table="termine">
<id name="TERMIN_ID" column="TERMIN_ID">
<generator class="identity"/>
</id>
<property name="description" column="description" type="java.lang.String"/>
<property name="comment" column="comment" type="java.lang.String"/>
<property name="open" column="open" type="java.lang.Integer"/>
<property name="start" column="start" type="java.lang.Long"/>
<property name="end" column="end" type="java.lang.Long"/>
<property name="starttime" column="starttime" type="java.lang.Long"/>
<property name="updatetime" column="updatetime" type="java.lang.Long"/>
<property name="place" column="place" type="java.lang.String"/>
<property name="owneruser" column="owneruser" type="java.lang.Integer"/>
<property name="terminstatus" column="terminstatus" type="java.lang.Integer"/>
</class>
</hibernate-mapping>
The row IS deleted i just get this Error-Message and i don't know why. First i thought the Object could still be in cache and when hibernate tries to update the objects it realizes that this object isn't there anymore.
I got no clue why, plain SQL-Queries work well, for example:
Code:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
String hqlDelete = "delete contactgroups where CONTACT_ID = :CONTACT_ID";
int deletedEntities = session.createQuery( hqlDelete )
.setInteger( "CONTACT_ID", CONTACT_ID )
.executeUpdate();
tx.commit();
HibernateUtil.closeSession();
works fine ...
thx
my System:
OS: debian woody
Database: 4.1.11-Debian_4
MySQL-Driver: mysql-connector-java-3.1.12-bin.jar
Hibernate-Version: version 3.1, Dec 12, 2005
Best,
Sebastian Wagner