Explorar el Código

add bulkDeleteWhere

tags/2.0.1
Jonathan Cobb hace 4 años
padre
commit
19e7392b8d
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. +10
    -0
      wizard-server/src/main/java/org/cobbzilla/wizard/dao/AbstractCRUDDAO.java

+ 10
- 0
wizard-server/src/main/java/org/cobbzilla/wizard/dao/AbstractCRUDDAO.java Ver fichero

@@ -360,6 +360,16 @@ public abstract class AbstractCRUDDAO<E extends Identifiable>
return count;
}

public int bulkDeleteWhere(String whereClause) {
final Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
final String deleteSql = "DELETE FROM " + getEntityClass().getSimpleName() + " WHERE " + whereClause;
final Query query = session.createQuery(deleteSql);
final int count = query.executeUpdate();
session.setFlushMode(FlushMode.COMMIT);
session.flush();
return count;
}

@Transactional(readOnly=true)
@Override public E findByUniqueField(String field, Object value) {
return uniqueResult(value == null ? isNull(field) : eq(field, value));


Cargando…
Cancelar
Guardar