use of de.invesdwin.context.persistence.jpa.api.query.DummyQuery in project invesdwin-context-persistence by subes.
the class QueryByExampleHelper method deleteByIds.
public Query deleteByIds(final EntityManager em, final Class<E> genericType, final Iterable<Long> ids) {
if (ids == null || !ids.iterator().hasNext()) {
return new DummyQuery();
}
final StringBuilder sb = new StringBuilder("DELETE FROM ");
sb.append(extractEntityName(genericType));
sb.append(" e WHERE ");
boolean first = true;
for (final Long id : ids) {
if (!first) {
sb.append(" OR ");
}
sb.append(IEntity.ID_COLUMN_NAME);
sb.append(" = ");
sb.append(id);
first = false;
}
final Query query = em.createQuery(sb.toString());
return query;
}
Aggregations