Java Code Examples for javax.persistence.criteria.CriteriaBuilder.createCriteriaDelete()

The following are Jave code examples for showing how to use createCriteriaDelete() of the javax.persistence.criteria.CriteriaBuilder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: tasfe-framework   File: BaseRepositoryImpl.java   Source Code and License Vote up 6 votes
@Override
public Integer deleteById(String id) {
	CriteriaBuilder cb = entityManager.getCriteriaBuilder();
	CriteriaDelete<T> delete = cb.createCriteriaDelete(getDomainClass());
	Root<T> e = delete.from(getDomainClass());
	delete.where(cb.equal(e.get("id"), id));
	return entityManager.createQuery(delete).executeUpdate();
}
 
Example 2
Project: tasfe-framework   File: BaseRepositoryImpl.java   Source Code and License Vote up 5 votes
@Override
public Integer deleteByFieldEq(String Field, Object value) {
	CriteriaBuilder cb = entityManager.getCriteriaBuilder();
	CriteriaDelete<T> delete = cb.createCriteriaDelete(getDomainClass());
	Root<T> e = delete.from(getDomainClass());
	delete.where(cb.equal(e.get(Field), value));
	return entityManager.createQuery(delete).executeUpdate();
}
 
Example 3
Project: tasfe-framework   File: BaseRepositoryImpl.java   Source Code and License Vote up 5 votes
@Override
public Integer deleteByFieldLike(String Field, String value) {
	CriteriaBuilder cb = entityManager.getCriteriaBuilder();
	CriteriaDelete<T> delete = cb.createCriteriaDelete(getDomainClass());
	Root<T> e = delete.from(getDomainClass());
	delete.where(cb.like(e.get(Field).as(String.class), value));
	return entityManager.createQuery(delete).executeUpdate();
}
 
Example 4
Project: tasfe-framework   File: BaseRepositoryImpl.java   Source Code and License Vote up 5 votes
@Override
public Integer deleteByFieldIn(String Field, Iterable<?> values) {
	CriteriaBuilder cb = entityManager.getCriteriaBuilder();
	CriteriaDelete<T> delete = cb.createCriteriaDelete(getDomainClass());
	Root<T> e = delete.from(getDomainClass());
	delete.where(cb.in(e.get(Field)).value(values));
	return entityManager.createQuery(delete).executeUpdate();
}