Changing associated entity during entity edit

I’ve got a mask where you can enter an invoice. During this process you are allowed to create and edit new companies (costumers / suppliers) and use them immediately. Also some values can be changed in the chosen company when hitting some buttons in the screen, where you actually edit the invoice.

I had to do this, to get it to work without errors:

invoice.setSupplier(dataContext.merge(dataManager.commit(supplierCompany)));

… where supplierCompany is an entity, that changed.

I only want to know, if this is the correct way of doing this?

Hi,
Yes, this looks correct.
However I would split this expression into separate expression on three lines, to simplify debugging in case if I need it in the future.

1 Like