Unable to save the Object

Hello Team,

I tried to set and commit an Entity (Transaction) status after a button clicked but I have this error:
image

I called a service like:

if(logic){
datamanager.commit();
}

and in Browse Interface:

 if( statusService.completeStatus(transations)){
       //     transactionsDl.load();
            getScreenData().loadAll();
        }

If I reopen the screen the modification is done!
Please advise!

I used invoked method from Button settings. Is better to subscribe to ActionPerformed Event?

Most probably you have to set the saved entity instance back to the screen data components like this:

if (logic) {
    MyEntity saved = dataManager.commit(myEntity);
    dataContext.merge(saved);
}

It worked!!
Meantime I used commitContext.addInstanceToCommit (MyEntity) that works as well but is no such consistent (maybe I have to use view as well).
Please explain a little bit the saving mechanism: why do I need to set saved entity instance back to the screen?
What are the differences between commitContext and dataContext?

getScreenData().loadAll();

is still necessary?

Thank you very much!
-n

Unfortunately, randomly, the error reappears.


Set<Transaction> trans = transactionsTable.getSelected();
for(Transaction a: trans){
 if (logic) {
                a.setStatus(statusone);
             //   commitContext.addInstanceToCommit(a);
               Transaction saved =  dataManager.commit(a);
                dataContext.merge(saved);

            }
            if (logic) {
                a.setStatus(statustwo);
            //    commitContext.addInstanceToCommit(a);
                Transaction saved =  dataManager.commit(a);
                dataContext.merge(saved);
            }
}

Result of dataContext.merge(saved) is ignored…