JDL also allows us to declare entity related options easily. Options currently supported are:
- service: By default, JHipster generates REST Resource classes that call the entity repositories directly. This is the simplest option, but in real-world scenarios, we might need a service layer to handle business logic. This option lets us create a service layer with a simple Spring service bean class or with a traditional interface and implementation for the service bean. Possible values are serviceClass and serviceImpl. Choosing the latter will create an interface and implementation, which is preferred by some people.
- dto: By default, domain objects are directly used in the REST endpoints created, which may not be desirable in some situations and you might want to use an intermediatory Data Transfer Object (DTO) to have more control. JHipster lets us generate the DTO layer using Mapstruct (http://mapstruct.org/), an annotation preprocessor library that automatically generates the DTO classes. It is advisable to use a service layer when using DTO. A possible value is mapstruct. For more info visit: http://www.jhipster.tech/using-dtos/.
- filter: This option lets us enable JPA based filtering capabilities for the entity. This works only when a service layer is used. For more details, visit: http://www.jhipster.tech/entities-filtering/.
- paginate: This option lets us enable pagination for an entity. This enables pagination on the Resource layer and also implements a paging option on the client side. Possible values are pager, pagination, and infinite-scroll.
- noFluentMethod: This lets us disable Fluent API style setters for the generated entity domain objects.
- skipClient/skipServer: These options let us either skip the client-side code or server-side code during generation.
- angularSuffix: This option lets us specify a suffix for the folder and class names in the frontend code.
The general syntax for option declaration is <OPTION> <ENTITIES | * | all> [with <VALUE>] [except <ENTITIES>].
The following are some possible options and different syntax in which they can be declared:
entity A
entity B
...
entity Z
dto * with mapstruct
service A with serviceImpl
service B with serviceClass
paginate * with pagination except B, C
paginate B, C with infinite-scroll
filter A, B