Search code examples
playorm

PlayOrm cascade entity removal


If I use the remove method of entity manager, as bellow:

DGEntity e = this.findById(id.toString(), entityClass);
getEm().remove(e);

and supposing DGEntity has a lot of associations with other entities, will the remove method remove only entity e or will it remove associated classes too?

I wish I could cascade delete if I want by configuring with annotations or by passing an additional argument to the method... Is this possible?


Solution

  • no, there are no cascades in playorm. There were many issues and tons of corner cases that made cascades in hibernate a huge debugging pain in tons of models. Since some models if you traverse them correctly could load the entire database into memory, that would also mean a cascade would need to delete every entity or be configured correctly. On top of that different use cases required the cascae to be needed sometimes and other use cases wanted cascade off so the best way was to never use cascade. We chose to not do cascade since it is easy enough to traverse your own model and do deletes and when the other use case pops up where you just want to delete the parent entity but not children, it is easier to code and not have to undo the cascade logic.

    I spent many an hour debugging the use of cascade on hibernate projects :(. I preferred not to do so again.