-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Document that JpaSpecificationExecutor.delete(…)
uses CriteriaDelete
and hence Cascades
are not considered
#2936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think it's a limitation of ORM, for performance concern, batch delete will not load them into memory then delete one by one. |
@quaff I don't understand what you mean. As I wrote, it works in |
You should do this if insist cascading jpaSpecificationExecutor.findBy(spec, q -> q.stream()).forEach(jpaRepository::delete) Please note it will be slow if result is large. |
@quaff thanks for explanation. I think it's not very consistent then and might be documented somewhere at least. I see developers using both of those methods (crud vs specs) and it leads to confusion mainly when ORM generates restrict by JPA definition. |
https://docs.oracle.com/javaee/7/api/index.html?javax/persistence/criteria/CriteriaDelete.html |
JpaSpecificationExecutor.delete(…)
uses CriteriaDelete
and hence Cascades
are not considered
JpaSpecificationExecutor.delete(…)
uses CriteriaDelete
and hence Cascades
are not considered JpaSpecificationExecutor.delete(…)
uses CriteriaDelete
and hence Cascades
are not considered
…te` and hence `Cascades` are not considered. Closes #2936
We updated our documentation to reflect that we're using |
Hello,
When executing
JpaSpecificationExecutor.delete(Specification<T> spec)
the related entities which containsCascadeType.ALL
are not deleted. However this works inCrudRepository.delete(T entity)
orCrudRepository.deleteById(ID id)
.Is this a bug (related to hibernate?) or is there any possibility to delete related entities with specification? I didn't found any info about this in documentation.
Sample app here with this test.
The text was updated successfully, but these errors were encountered: