Goal: UI with ability to remove entities from the database (this is one of the GDPR statements).
I have the following setup:
- Parent entity type (Parent).
- Child entity type (Child) with reference (One-To-One) to the parent:
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = “PARENT_ID”)
protected Parent parent;
- Both extends StandardEntity.
To do that I’ve extended default “Restore Deleted entities” screen and added custom “Remove” action to make it possible to set “Soft Delete” option to false in addBeforeCommitListener(). See this comment.
After that, when I click my “Remove” action I had the following error:
java.sql.SQLIntegrityConstraintViolationException: integrity constraint violation: foreign key no action;
I noticed that my foreign key doesn’t have “Delete rule” and set it manually to “Cascade” in the database.
After that, my entities are completely removed on “Remove” action. But CUBA studio generates DB script to update the foreign key without “Delete rule”.
Is it expected behavior? Can we ignore those updates and prevent their generation?
Also, please let me know if I’m doing something wrong