Cascade Update/Delete on Entity Merge

Hello, how do we use cascade when update delete when using entityManager.merge. I have this ff configuration:


@OneToMany(mappedBy = "order", cascade = CascadeType.MERGE)
protected List<SubClass> subClasses;


I have tried CascadeType.ALL and PERSIST but it is still not inserting any record on SubClass table. Also, what we need is that if there is a record in the database that is not in the subClassese list, it will be deleted or detached.

Thank you


JPA cascade should work in general, however it’s not recommended (see the docs).

If you work with this MainClass / SubClass relationship in Generic UI, it will be persisted automatically, because DataContext of the screen will save both the master and the collection elements using DataManager. If you do it in some business logic, maintain the collection from the owning side by saving/deleting the items.

Thank you and noted on the reply :slight_smile: