Annotations
Each entity, attribute or link can have 0 to N annotations.
Annotations provide additional information usable during the code generation.
An annotation is a predefined name starting with "@".
Some annotations may have values specified between "(" and ")".
For attributes and links all annotations must be located in the block delimited by "{" and "}".
NB : since version 4.0 the useless comma between annotations is prohibited and must be removed
Marks an entity as "abstract"
Scope : entity / Since : 4.0.0
Marks an entity as "aggregate root" (useful to define "DDD aggregates" )
Scope : entity / Since : 4.0.0
The attribute is supposed to be auto-incremented (for example for an auto-incremented key)
Only applicable to numeric types
Scope : attribute / Since : 2.0.0
Defines how to manage ORM "cascade" options for a link
Valid options : ALL or A, MERGE or M, PERSIST or P, REFRESH or REF, REMOVE or REM
Scope : link / Since : 4.1.0
Examples :
@Cascade(MERGE) @Cascade(REMOVE) @Cascade(MERGE,REMOVE) @Cascade(M,REM)
Defines the context to which the entity belongs
Scope : entity / Since : 4.0.0
Defines the database catalog to which the entity table belongs
Scope : entity / Since : 4.0.0
The comment in the database (typically a column comment or table comment in a relational database)
Scope : attribute & entity / Since : 3.2.0 for attribute, 4.0.0 for entity
The default value in the database.
Scope : attribute / Since : 3.2.0
The name in the database (for example the column name in a relational database)
Scope : attribute / Since : 3.2.0
Defines the database schema to which the entity table belongs
Scope : entity / Since : 4.0.0
Deprecated - Do not use
Scope : attribute / Since : 3.2.0
Defines the database table associated with the entity
Scope : entity / Since : 4.0.0
Defines the database tablespace where the entity table is located
Scope : entity / Since : 4.0.0
The attribute type in the database (for example the column type in a relational database)
Scope : attribute / Since : 3.2.0
Marks the entity as a "view" in the database
Scope : entity / Since : 4.0.0
The default value for an attribute
Scope : attribute / Since : 3.2.0
Defines the "domain" to which the entity belongs
Scope : entity / Since : 4.0.0
The entity referenced by the attribute must be embedded (typically for NoSQL databases).
Applicable with "references" to embed them in the current entity.
Scope : link / Since : 3.0.0
Defines the "superclass" of an entity (inheritance)
Scope : entity / Since : 4.0.0
Define an "Eager Loading" fetch type for a link, typically for ORM (JPA, Doctrine, etc ).
Scope : link / Since : 3.3.0
Define a "Lazy Loading" fetch type for a link, typically for ORM (JPA, Doctrine, etc ).
Scope : link / Since : 3.3.0
Define a "Foreign Key" or a "Foreign Key part"
Scope : attribute / Since : 3.3.0
Syntax :
// FK referencing an entity with a basic PK (single attribute)
@FK( ReferencedEntity ) // without FK name (default name)
@FK( ForeignKeyName, ReferencedEntity ) // with FK name
---
// FK referencing an entity with a compositePK (N attributes)
@FK( ForeignKeyName, ReferencedEntity.ReferencedAttribute )
Examples :
// FK referencing "Brand" entity (with default FK name)
brandId : int { @FK(Brand) }; // PK inference
-----
// FK referencing "Brand" entity (with default FK name)
brandId : int { @FK(Brand.id) }; // explicit PK attribute
-----
// FK referencing "Group" entity (with FK name)
groupCode : string { @FK(FK_EMP_GRP, Group) } ;
-----
// FK referencing "SubGroup" entity (composite PK)
groupCode : string { @FK(FK_PER_SUBGRP, SubGroup.groupCode ) };
subgroupId : int { @FK(FK_PER_SUBGRP, SubGroup.subgroupId) };
The attribute date value must be in the future (after current date).
Usable for field validation rules. Applicable with "date" type.
Scope : attribute / Since : 2.0.0
Defines the generated value strategy ("AUTO", "IDENTITY", SEQUENCE" or "TABLE") for an attribute.
Scope : attribute / Since : 3.4.0
Syntax :
@GeneratedValue(AUTO)
@GeneratedValue(IDENTITY)
@GeneratedValue(SEQUENCE [, GeneratorName, SequenceName
[, AllocationSize ] ])
@GeneratedValue(TABLE [, GeneratorName, TableName
[, PkColumnName, PkColumnValue, ValueColumnName [, AllocationSize ] ] ])
The attribute is the "ID" (or "Primary Key") for the current entity.
For an entity with a composite ID (composite Primary Key), put this annotation on each attribute that is part of the ID.
Scope : attribute / Since : 1.0.0
Applicable with any basic type.
For a composite Primary Key just put an "@Id" annotation for each attribute that is part of the key.
Examples :
Badge { // Simple key => single "@Id"
id : int { @Id } ;
name : string ;
}
SubGroup { // Composite key => multiple "@Id"
groupCode : string { @Id } ;
sectionId : int { @Id } ;
name : string ;
}
Sets the initial value of the attribute.
Scope : attribute / Since : 3.2.0
Marks an entity as fully stored in memory.
All occurrences can be accessed directly in memory (can be useful for static datasets).
Scope : entity / Since : 4.0.0
Defines the input type usable for a field (for example an HTML input type).
Scope : attribute / Since : 3.2.0
Defines if the link is "insertable" or not.
Scope : link / Since : 3.3.0
Examples :
@Insertable(true)
@Insertable(false)
Marks the current entity as a "Join Entity" (an entity referencing two other entities in order to manage a many-to-many relationship).
Scope : entity / Since : 4.1.0
Defineabel(string)
Defines the label usable for the field (for example an HTML label).
Scope : attribute / Since : 3.2.0
Defines a link based on the given attribute(s) name(s) referencing the Primary Key.
For multiple attributes (in case of composite PK) each attribute must define the referenced attribute in the target entity.
Scope : link / Since : 3.3.0
Syntax :
// simple PK with a single attribute :
@LinkByAttr(attributeName)
// composite PK with N columns (in PK order) :
@LinkByAttr(attributeName1, attributeName2 [, attributeNameX ] )
Example :
Point {
x : int { @Id @DbName(X) } ; // PK
y : int { @Id @DbName(Y) } ; // PK
name : string ;
}
Line {
id : int { @Id } ;
color : string ;
point1X : int { @DbName(X1) } ;
point1Y : int { @DbName(Y1) } ;
point2X : int { @DbName(X2) } ;
point2Y : int { @DbName(Y2) } ;
// LINKS
point1 : Point { @LinkByAttr(point1X , point1Y ) } ;
point2 : Point { @LinkByAttr(point2X , point2Y ) } ;
}
Defines a link based on the given Foreign Key name.
Scope : link / Since : 3.3.0
Syntax :
@LinkByFK(foreignKeyName)
Example :
Area {
id : int { @Id } ;
name : string ;
// Foreign Key
countryCode : string { @FK(FK_AREA_COUNTRY, Country) } ;
// Link definition based on Foreign Key
country : Country { @LinkByFK(FK_AREA_COUNTRY) } ;
}
Defines a link based on the given "join entity" name.
Usable with "many to many" links to define a "join table".
Scope : link / Since : 3.3.0
Syntax :
@LinkByJoinEntity(entityName)
Example :
Employee {
id : int { @Id } ;
name : string ;
// EmployeeGroup is a "join entity" to associate employees and workgroups
workgroups : Workgroup[] { @ManyToMany
@LinkByJoinEntity(EmployeeGroup) } ;
}
Marks the attribute as "long text" (for example a text with several lines).
This annotation can be used for HTML "text area" or database "CLOB".
Applicable with "string" basic type.
Scope : attribute / Since : 2.0.0
Defines a "many to many" cardinality for a link.
Usable for ORM code generation (JPA, etc)
Scope : link / Since : 3.3.0
Defines the "mappedBy" attribute for a link.
Usable for an "inverse side" relationship.
Scope : link / Since : 3.3.0
Example :
shops : Shop[] { @MappedBy(employee) } ;
To set the maximum acceptable value.
Usable for field validation rules.
Applicable with "numeric" types.
Scope : attribute / Since : 2.0.0
To set the maximum acceptable length.
Usable for field validation rules and GUI fields definition.
Scope : attribute / Since : 4.0.0 (replaces "@SizeMax" )
To set the minimum acceptable value.
Usable for field validation rules.
Applicable with "numeric" types.
Scope : attribute / Since : 2.0.0
To set the minimum acceptable length.
Usable for field validation rules and GUI fields definition.
Scope : attribute / Since : 4.0.0 (replaces "@SizeMin" )
The attribute value cannot be blank.
Usable for field validation rules.
Scope : attribute / Since : 2.0.0
The attribute value cannot be empty.
Usable for field validation rules.
Scope : attribute / Since : 2.0.0
The attribute value cannot be null.
Usable for field validation rules and SQL databases.
Scope : attribute / Since : 2.0.0
The attribute type must be converted to "object/wrapper type" in the target language (for example for Java).
No effect if not supported by the target language.
Applicable with any basic type.
Scope : attribute / Since : 2.0.0
Defines a "one to one" cardinality for a link.
Usable for ORM code generation (JPA, etc)
Scope : link / Since : 3.3.0
Defines an "optional" relationship for a link.
Usable for ORM code generation (JPA, etc)
Scope : link / Since : 3.3.0
Set 'orphanRemoval' to true in ORM (JPA, etc)
Scope : link / Since : 4.1.0
Defines the "package" to which the entity belongs
Scope : entity / Since : 4.0.0
The attribute value must be in the past (before current date).
Usable for field validation rules.
Applicable with "date" type.
Scope : attribute / Since : 2.0.0
Defines a pattern usable for field validation, for example a "RegEx" pattern.
Scope : attribute / Since : 3.2.0
The attribute type must be converted to "primitive type" in the target language (for example for Java).
No effect if not supported by the target language.
Applicable with any basic type.
Scope : attribute / Since : 2.0.0
Marks the entity as "readonly"
Scope : entity / Since : 4.0.0
Defines the attribute size.
The size is defined with "precision" and "scale" if necessary (eg "6" or "6,2")
Scope : attribute / Since : 4.0.0
Deprecated - Do not use - Use "@MaxLen" instead
Defines the maximum acceptable size of the attribute value.
Scope : attribute / Since : 2.0.0
Deprecated - Do not use - Use "@MinLen" instead
Defines the minimum acceptable size of the attribute value.
Scope : attribute / Since : 2.0.0
Define an attribute as "transient" (for example in a Java class or with an ORM like JPA)
Scope : attribute / Since : 3.3.0
Marks the attribute as unique for the entity.
Scope : attribute / Since : 4.0.0 (experimental)
The attribute type must be converted to "unsigned type" in the target language (for example for C/C++).
No effect if not supported by the target language.
Applicable with any basic type.
Scope : attribute / Since : 3.0.0
Defines if the link is "updatable" or not.
Scope : link / Since : 3.3.0
Examples :
@Updatable(true)
@Updatable(false)
Last modified 1mo ago