ModelMapper, mapping list of Entites to List of DTO objects You can create util class: public class ObjectMapperUtils { private static final ModelMapper modelMapper; ** * Model mapper property setting are specified in the following block
ModelMapper: Choose mapping based on Child class in the conversion service method add an object mapper with ignore unknown (to ignore what you did not declare in your DTO class) ObjectMapper objectMapper = new ObjectMapper(); objectMapper configure(DeserializationFeature FAIL_ON_UNKNOWN_PROPERTIES, false); just simply call :
Configure ModelMapper to map nested object to field usage of these mapper is as follow private SimpleSourceDestinationMapper mapper = Mappers getMapper(SimpleSourceDestinationMapper class); TagVolumeDTO destination = mapper sourceToDestination(tag); Kindly find link for detailed implementation MapStuct
How to use Explicit Map with Java 8 and ModelMapper? if the source and destination type are different For example, @Entity class Student { private Long id; @OneToOne @JoinColumn(name = "laptop_id") private Laptop laptop; }
How to use modelMapper to convert nested classes I have a simple class that I want to map to a DTO class using modelMapper class Source { private String name; private String address; List lt;Thing gt; things; getters and se