Skip to content

Entity is updated which specified as new property value of commit instance #13

@kandalin-d

Description

@kandalin-d

Environment

  • Platform version: 7.2-SNAPSHOT
  • Addon version: 1.1.0

Description of the bug or enhancement

  • Minimal reproducible example
    By use http://localhost:8080/app-portal/api/commit request
    try to update existing entity (without specified view !) with setting reference property to the new value.
    Bug is reproducing only if reference entity (specified as new property value) has @PostConstruct method in which some fields are initializing by not null values (or some entity fields are initializing in field declaration).

For example (request body):

{
  "commitInstances": [
    {
      "id": "df$DocKind-c40ea551-d399-4a11-b6be-347ca5f27837",
      "numerator": {
        "id": "df$Numerator-70dfe954-fe9d-11e2-96e0-1f9c56fc4e22"
      }
    }
  ]
}
  1. "df$DocKind-c40ea551-d399-4a11-b6be-347ca5f27837" - without view
  2. "df$Numerator-70dfe954-fe9d-11e2-96e0-1f9c56fc4e22" - new reference property value
  3. Entity 'df$Numerator' has @PostConstruct method:
    @PostConstruct
    protected void init() {
        setPeriodicity(PeriodicityType.YEAR);
        setScriptEnabled(false);
        setNumberInitialValue(1);
    }

These 3 fields of Numerator entity will be really updated after merge DocKind.

see:
com.haulmont.addon.jpawebapi.api.controller.DataServiceController#commit

// reference to an existing entity
                            Object refEntityId = refEntity.getId();
                            refEntity = metadata.create(refEntity.getMetaClass());

                            //noinspection unchecked
                            ((BaseGenericIdEntity) refEntity).setId(refEntityId);

com.haulmont.cuba.core.sys.EntityManagerImpl#merge(T)
com.haulmont.cuba.core.sys.EntityManagerImpl#deepCopyIgnoringNulls

  • Expected behavior
    Entity which specified as new property value is not updated.
    (DocKind is updated, Numerator is not, for example)
  • Actual behavior
    The commit instance and entity which specified as new property value are updated.

Metadata

Metadata

Labels

type: regressionIssue was found during regression

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions