I'm using spring-data-mongodb 1.2.0 with QueryDSL 2.9.0.
Why doesn't the QueryDslPredicateExecutor
have a delete(Predicate predicate)
method?
Is there a workaround?
What you can probably do is this. With the predicate for "where" condition, query for the objects and then pass that to the delete method
QMyObj obj= new QMyObj("myObj");
Iterable<MyObj> myObjs = myObjRepository.findAll(obj.property.eq("property"));
myObjRepository.delete(myObjs);
Here I am first creating an instance of the Q class and then finding all the objects based on the predicate. Then calling the repository's void delete(Iterable<? extends T> entities)
method.
May be it is because of this workaround they don't provide it, but that is for the Spring Source guys to confirm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With