@OnCascade(DeletePolicy.DELETE) does not work

Hello guys,

I have the following entities: Inner, InnerLevel2, InnerLevel3. InnerLevel3 is contained (@Composition) in InnerLevel2 and InnerLevel2 is contained (@Composition) in Inner.

The use case is:

  1. I open the single entity browser I have in my project.
  2. I create the Inner entity.
  3. In the create dialog, I create the InnerLevel2 entity.
  4. In InnerLevel2's create dialog, I create the InnerLevel3 entity.
  5. I click OK on all dialogs and everything is created.
  6. I select the entity from the table, then I press on the button next to the create button.
  7. This button calls a method in a service that deletes the selected item and I go to entity inspector to check whats up.
  8. Inner entity is deleted, but the other entities that SHOULD have been cascaded are still there.

I expected that deleting Inner would cascade the deletion of InnerLevel2 that would cascade the deletion of InnerLevel3. This does not happen.

This is a recurring issue I have in a bigger project of mine.

Platform version 6.10.14

Please tell me if my understanding is correct and if so, why is the expected behavior not happening.

Thanks,
Alex

Demo project
delete-test.zip (89.5 KB)

4 Likes

Hi,
Thank you for reporting the problem.
The problem has been fixed in the 7.1 version. See issue: EntityManager.flush() breaks cascade deletion policy · Issue #785 · cuba-platform/cuba · GitHub

1 Like

Hello, Andrey,

Thank you for the reply. Is the fix coming for CUBA 6 based projects?

Thanks,
Alex

Hi Alex,
We are going to include fix in the next update release 6.10.

Thank you,
Andrey

1 Like

That is awesome!

Thanks, Andrey!