custom primary key

Hi

we reversed engineered the model from an existing database. The primary key of an Entity is a String which represents an Enum. This field does not appear in the Attributes section and when using the Editor this field can’t be updated. Also if we create a new entity then we can’t specify the value for this field.

What do we need to configure to make this field editable?

Thanks,
Oliver

Hi Oliver,

Try to add the field to the editor’s field group manually. Studio now doesn’t add primary key attributes to generated screens, which is probably wrong for String-ID entities. We’ll fix it, see the linked issue.

Hi Konstantin,

it results in an validation error:
[08:23:25.724] Validation error
Attribute with the same name already exists

The source of the attribute :
@Id
@Column(name = “adspace”, nullable = false, length = 50)
protected String adspace;

Any other workaround?

Thanks,
Oliver

You are probably trying to add an attribute to the entity. But I mean just adding a field for the existing attribute to the editor screen, for example:


<layout spacing="true">
    <fieldGroup id="fieldGroup" datasource="currencyDs">
        <column width="250px">
            <field id="code"/> <!-- primary key, was not here initially -->
            <field id="name"/>
        </column>
    </fieldGroup>
    <frame id="windowActions" screen="editWindowActions"/>
</layout>

yes, that works, thank you very much!

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

https://youtrack.cuba-platform.com/issue/STUDIO-3206