Association from additional data store not saved in the database

Hi guys,

On main datastore on User entity I attached a Customer entity as association, many to one.
Customer entity is from a second (additional) datastore.
Because the new added customer field is transient, I’ve created an additional field (named customerId) in User entity when asked by Studio.

On the UserEdit screen I’ve added a combo selection for this new added field:

<entityComboBox id="cmbCustomer" caption="Customer"
        <action id="clear" type="entity_clear"/>

The customer selection works ok, but after saving user entity, the customerId column in the database is empty (null).
I had to do the update adding extra unnecessary code in controller. Similar, when opening User screen, the customerId is not retrieved from the database.

Is this a normal behaviour for cross datastore associations? I hope not :).


Hi Camil.

Thank you for reporting the problem. We have created a Github issue.


The problem is reproduced only if no other attributes are changed in the editor. The reason is explained in the issue - transient attribute doesn’t call property listeners, so DataContext of the screen is not notified about changes and doesn’t save the entity at all.

Until the issue is fixed in the framework, you can work around it in your project by calling the listeners explicitly:

public class User implements JmixUserDetails {
    // ...

    public void setCustomer(Customer customer) {
        EntityInternals.fireListeners((io.jmix.core.Entity) this, "customer", this.customer, customer);
        this.customer = customer;