QueryDSL Removal Method

I am using spring -data-mongodb 1.2.0 with QueryDSL 2.9.0.

Why QueryDslPredicateExecutor n't QueryDslPredicateExecutor have a delete(Predicate predicate) method?

Is there any workaround?

+8
source share
2 answers

What you can do is. With a predicate for the where clause, query for the objects, and then pass this to the delete method

 QMyObj obj= new QMyObj("myObj"); Iterable<MyObj> myObjs = myObjRepository.findAll(obj.property.eq("property")); myObjRepository.delete(myObjs); 

Here, I first instantiate the Q class, and then find all the objects based on the predicate. Then the void delete(Iterable<? extends T> entities) repository method void delete(Iterable<? extends T> entities) called.

Perhaps this is because of this workaround that they do not provide, but for Spring, the original guys confirm

+3
source

using JPADeleteClause, pass it the following two parameters: entityManager and EntityPath QClass

 QPersonEntity path = QPersonEntity.personEntity; JPADeleteClause deleteClause = new JPADeleteClause(getEntityManager(), path); deleteClause.where(path.name.eq("behrooz")).execute(); 
-one
source

All Articles