ExcludeAction implementation wrong for many-to-many relations

I have a combined browse-edit screen to edit an entity that has a many-to-many relation to another entity. The edited entity is the owning side, so it should be ok adding/excluding items from the association.

So Studio added automatically a table to add/exclude items from the association collection. But ExcludeAction doesn’t work as expected, it simply doesn’t set the modified state of the CollectionDatasource attached to the table (so the commit is a no-op if you don’t change other properties of edited entity, because modified=false).

The wrong code is in the doRemove method, and in particular this loop:

for (Object item : selected) {
    ds.excludeItem((Entity) item);

I have overridden the method in a custom action, and replaced with a call to removeItem, and now it works as expected.

In addition, at the beginning of the same method (doRemove) I think that you have missed a check in this condition

if (inverseProp != null) {

, you should also check that



After some attempts, this is what I found:

  • ExcludeAction is basically used only for ONE-TO-MANY associations, and doesn’t work reliably for anything else
  • RemoveAction works for plain entity removals (aka DELETEs), and for MANY-TO-MANY associations but only on the owning side. It doesn’t work on the mappedBy side of the association.
  • AddAction work for associations, but it doesn’t work on the mappedBy side (non-owning side) of a MANY-TO-MANY association
    My test users are confused by this exclude/remove differentiation for the associations, it is too much a technical detail for them. They like to have a consistently named button, and for me it is Remove for deleting records, and Exclude from deleting associations.
    And they like to be able to remove a MANY-TO-MANY association on both sides of the relation, something that could not be achieved by standard actions.
    For the above reasons I replaced the standard AddAction and ExcludeAction to deal with these points:
  • ExtAddAction can add from both sides of a MANY-TO-MANY association (by creating a hidden datasource and adding to the other side collection)
  • ExtExcludeAction deal with any type of association, and on both sides of MANY-TO-MANY associations. Now I can use Exclude consistently for all associations, while Remove only for deleting entities.
    If anyone else is interested in these new actions, I’ll post them somewhere.


The issue is known. We are going to fix it some day.

Thank you.

ExcludeAction behaviour has been fixed in issue: https://youtrack.cuba-platform.com/issue/PL-7515 Fix will be available since Release 6.6

:ticket: See the following issue in our bug tracker: