int delete(DBTransaction trx, String query, Object value, Type type) {
int deleted = 0;
if (trx.isRolledBack() || trx.isCommitted()) { // some program bug
throw new DBRuntimeException("cannot delete in a transaction that is rolledback or committed " + value);
}
try {
//old: deleted = getSession().delete(query, value, type);
Session si = getSession();
Query qu = si.createQuery(query);
qu.setParameter(0, value, type);
List foundToDel = qu.list();
int deletionCount = foundToDel.size();
for (int i = 0; i < deletionCount; i++ ) {
si.delete( foundToDel.get(i) );
}
if (Tracing.isDebugEnabled(DBManager.class)) {
logQuery("delete (trans "+trx.hashCode()+")",new Object[] {value}, new Type[] {type}, query);
}
} catch (HibernateException e) { // we have some error
trx.setErrorAndRollback(e);
throw new DBRuntimeException ("Could not delete object: " + value, e);
}
return deleted;
}