Application modeling using JDL

In Chapter 4, Entity Modeling with the JHipster Domain Language, we learned how to define entities and relationships using JDL. Now, let's learn how to define applications.

In the following syntax, take note of the following:

  • [] denotes optional.
  • * denotes more than one can be specified.

JavaDocs can be added to entity declarations, while /** */ Java comments can be added to fields and relationship declarations. JDL-specific comments can only be added using the // syntax.

It is also possible to define numerical constants in JDL, for example, DEFAULT_MIN_LENGTH = 1.

The application declaration is created using the following syntax:

application {
config {
<option> <value>
}
[entities <entity names(comma seperated)>* [except] [<entity
names(comma seperated)>*]]
}

<option> is one of the supported application options, followed by <value>, which is supported by the option. If an option is not declared, a default value will be used instead. Refer to the table at https://www.jhipster.tech/jdl/applications#available-application-options for all the supported options and defaults.

The entities keyword is used to associate the entities applicable to a particular application. entities * will denote that all the entities declared in the file are associated with an application. Fine-grained declarations are possible using the given syntax; for example, entities * except C, D or entities A, B.

An example of an application declaration is as follows:

application {
config {
baseName myapp
applicationType microservice
prodDatabaseType postgresql
buildTool gradle
}
}

With entities, it would look as follows:

application {
config {
baseName myMonolith
applicationType monolith
}
entities * except C, D
}

entity A
entity B
entity C
entity D

Let's proceed and design our JDL.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset