Problems modifying embedded entity records

I have two embedded entities, Contact and Address. I perform the normal process of associating my entities with a particular entity such as Company. I believe the view and until that moment everything is correct. The problem occurs when editing an already created record, which does not contain data in the embedded entities.
At the moment of doing this by positioning myself in the field, I simply write something and when it exits the information is deleted, if I try several times it leaves the data but when saving the changes, they are simply deleted.
Attached is a small project where you can observe this particularity.
I appreciate any help on this

Nelson F (10.9M)

1 Like

Hi Nelson,

Thank you for your project.

We are going to fix this issue in the platform some day.

As a workaround, you can solve the problem by adding the @EmbeddedParameters(nullAllowed = false) annotation to @Embedded attribute. And initiate embedded Address and Contact during a Company creation.

        @AssociationOverride(name = "city", joinColumns = @JoinColumn(name = "ADDRESS_CITY_ID")),
        @AssociationOverride(name = "district", joinColumns = @JoinColumn(name = "ADDRESS_DISTRICT_ID")),
        @AssociationOverride(name = "region", joinColumns = @JoinColumn(name = "ADDRESS_REGION_ID")),
        @AssociationOverride(name = "zone", joinColumns = @JoinColumn(name = "ADDRESS_ZONE_ID"))
        @AttributeOverride(name = "address", column = @Column(name = "ADDRESS_ADDRESS")),
        @AttributeOverride(name = "latitude", column = @Column(name = "ADDRESS_LATITUDE")),
        @AttributeOverride(name = "longitude", column = @Column(name = "ADDRESS_LONGITUDE"))
    @EmbeddedParameters(nullAllowed = false)
    protected BaseAddress address;

        @AttributeOverride(name = "telephone", column = @Column(name = "CONTACT_TELEPHONE")),
        @AttributeOverride(name = "extension", column = @Column(name = "CONTACT_EXTENSION")),
        @AttributeOverride(name = "cellPhone", column = @Column(name = "CONTACT_CELL_PHONE")),
        @AttributeOverride(name = "email", column = @Column(name = "CONTACT_EMAIL")),
        @AttributeOverride(name = "web", column = @Column(name = "CONTACT_WEB"))
    @EmbeddedParameters(nullAllowed = false)
    protected BaseContact contact;

    public void init() {
        Metadata metadata = AppBeans.get(Metadata.NAME);
        address = metadata.create(BaseAddress.class);
        contact = metadata.create(BaseContact.class);

Thanks Rostislav, the solution works very well.

:ticket: See the following issue in our bug tracker: