One-to-one generate values


I have a one to one relation between two entities Transaction and Credit.
In the Credit I have inverse attribute of the Transaction (no column ID).
Now when I create a new Transaction I want to create a new Credit as well and display the attributes of the Credit in Transaction Browser an also in the Credit Browser.
(For Transaction and Credit is generated automatically from Listener (onBeforeInsert) - TransactionRegNr and CreditRegNr.)

I made it in this way:

public class TranzactionEdit extends StandardEditor<Transaction> {
 @Subscribe(target = Target.DATA_CONTEXT)
    public void onPostCommit(DataContext.PostCommitEvent event) {
        Credit credit = metadata.create(Credit.class);
        credit.setTransaction(getEditedEntity());//otherwise I have null pointer exception
        CommitContext commitContext = new CommitContext().addInstanceToCommit(credit);

Thus I generated a new Credit record but I cannot see the inverse attribute TransactionRegNr in the Credit Browser . The solution is to check Owning side (in Credit/transaction) and generate a new column TRANSACTION_ID.

The problem is that in Credit Browser I cannot see TransactionRegNr anymore (except those created from Transaction Edit) - because all values of new created TRANSACTION_ID arenull. Even I create a new record the TransactionRegNr is empty. The solution is to uncheck Credit/transaction Owning side again.
It’s kind of chicken and egg story.

Is there any workaround?


You should be able to have a single owning side for one-to-one relationship and load needed attributes using appropriate views in screens.
A test project would be helpful to understand the problem.

Finally I manage to succeed: I committed both entities.
However I don’t understand why is necessary to commit Transaction entity as well. I expected to be done by the commitandClose() button!