Entity / DTO mapping

Entity / DTO mapping converts a model object (entity) into an exchange object and vice versa, so the entity is not exposed to the API. It is written by hand in a dedicated method or with a generation tool such as MapStruct. It should stay in one place, often in the service layer.

Example

ClientResponse toDto(Client c) { return new ClientResponse(c.getId(), c.getNom()); }

Related concepts

The whole glossary