What is the difference between the 2 options above? When is it preferable to choose each option?
相关问题
- Symfony2 Set Controller in the kernelControllerEve
- Webpack Encore: cannot import local dependencies
- Render custom attribute KNP Menu
- Problems with cap deploy a symfony2 project, can
- Allow CORS on symfony 4
相关文章
- Hibernate doesn't generate cascade
- Symfony : Doctrine data fixture : how to handle la
- Symfony is linked to the wrong PHP version
- Symfony2: check whether session exists or not
- Is there a way to modify the entity mapping config
- symfony2 form choice and mongodb
- Symfony 3.1 and OneUpUploaderBundle + Blueimp = Up
- Symfony does not remove entity from collection
The basic difference between them is:
Say your
User
has one-to-many relation toComment
. If you are usingcascade="remove"
, you can remove the reference forComment
from oneUser
, and then attach thatComment
to anotherUser
. When you persist them, they will be correctly saved. But if you are usingorphanRemoval=true
, even if you will remove givenComment
from oneUser
, and then attach to anotherUser
, this comment will be deleted during persist, because the reference has been deleted.