Skip to main content
Question

When to use @ID & @GeneratedValue annotations in Appian?

A
Anonymous
December 18, 2025

Answer

We use the @Id and @GeneratedValue annotations when you map a Custom Data Type (CDT) to a database table. They define the primary key and how its value is assigned when a record is created.


@Id :

@Id marks the CDT field that is the primary key, the value that uniquely identifies each row in the table. Use it on its own when your application or another system supplies the key, so the database does not generate it.


@GeneratedValue:

@GeneratedValue goes alongside @Id when the key should be generated automatically, typically by a database auto-increment column. It works only if the database and your Appian configuration support that strategy.

Example CDT configuration


Xml Code:

<xsd:element name="formId" nillable="true" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@GeneratedValue
@Column(name="FORM_ID", nullable=false,
unique=true, columnDefinition="INT UNSIGNED")
</xsd:appinfo>
</xsd:annotation>
</xsd:element>


Here @Id makes formId the primary key, and @GeneratedValue tells Appian the value is generated automatically. @Column maps the field to the FORM_ID column and sets its properties. When a new form record is saved, the database might assign FORM_ID = 101. The actual number depends on the current sequence or auto-increment state.


Scenario

Configuration

The application supplies the primary key

@Id

The database generates the primary key

@Id and @GeneratedValue

The CDT maps to an existing table

Check the table’s existing primary key and generation strategy first

Common mistake

Adding @GeneratedValue does not make the database generate identifiers. The column and the CDT mapping have to agree. With MySQL, for example, the column itself must be set up as auto-increment.


Official Appian documentation: Mapping CDTs to Pre-defined Database Tables

JuniorData Type