The entity declaration is done using the following syntax:
entity <entity name> ([<table name>]) {
<field name> <type> [<validation>*]
}
<entity name> is the name of the entity and will be used for class names and table names. Table names can be overridden using the optional <table name> parameter.
<field name> is the name of the fields (attributes) you want for the entity and <type> is the field type, as in String, Integer, and so on. Refer to http://www.jhipster.tech/jdl/#available-types-and-constraints for all supported field types. The ID field will be automatically created and hence need not be specified in JDL.
<validation> is optional and one or more <validation> for the fields can be specified depending on the validation supported by the field type. For validations such as max length and pattern, values can be specified in braces.
An example entity declaration would look like the following:
/**
* This is customer entity javadoc comment
* @author Foo
*/
entity Customer {
/** Name field */
name String required,
age Integer,
address String maxlength(100) pattern(/[a-Z0-9]+/)
}
Enumerations can also be declared using the following syntax:
enum <enum name> {
<VALUE>*
}
Here is an example:
enum Language {
ENGLISH, DUTCH, FRENCH
}