Committing non related entity with the screen-commit

Hi,
I am using Cuba Platform Version 7.26 and I am looking for an simple way to add
some non-related entities in the commit-transaction of a screen (StandardEditor<>).
The reason is locking. I want to force versioning of this entities, which are related in the screen (without changing them) so that another user, who is working on the same entities is warned on save (or vice versa).

I tried to do something like:

Entity e1 = persistence.getEntityManager(dataStoreName).find(entity.class, id);
Entity e2 = persistence.getEntityManager(dataStoreName).find(entity.class, id);

then
e1.setDummyAttr(“new”);
e2.setDummyAttr(“new”);

and so on.

I tried in the onBeforeCommitChanges(…) - event
something like:

getScreenData().getDataContext().merge(e1);
getScreenData().getDataContext().merge(e2);

with no result at committing.

So what is wrong in this way ?

Regards,
Martin

Hello, I think I found a way:

in

BeforeCommitChanges(BeforeCommitChangesEvent event)

i did the following:

dataContext.addPreCommitListener(c-> {
   for (MyEntity f: entitesForLocking) {
         f.setDummyField("TEST");
              c.getModifiedInstances().add(f);
        }
});

Then this entitys are save with the mask-entities (in same transaction) and in that way
concurrend changes are found.

Regards,

Martin