I think you don't can execute deletes or updates with session.
createQuery().
If you're working with Spring's
HibernateTemplate you can do bulk updates.
Code:
getHibernateTemplate().bulkUpdate( "delete from EmpBean as where eb.no>=? and eb.no<=?", new Object[] {100L, 200L} );
This is the
HibernateTemplate.bulkUpdate():
Code:
public int bulkUpdate(final String queryString, final Object[] values) throws DataAccessException {
Integer updateCount = (Integer) executeWithNativeSession(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {
for (int i = 0; i < values.length; i++) {
queryObject.setParameter(i, values[i]);
}
}
return new Integer(queryObject.executeUpdate());
}
});
return updateCount.intValue();
}