I configure my modelmapper like so
@PostConstruct
private void initMapper() {
PropertyMap<TalTicketEntity, TicketDto> talTicketToTicketPropertyMap = new PropertyMap<TalTicketEntity, TicketDto>() {
@Override
protected void configure() {
map(source.getSymphonyId()).setId(null);
map().setDetails(new TicketDetailsDto());
map(source.getThirdPartyId()).getDetails().getExternalTicket().setExternalId(null);
map(source.getRequester()).getDetails().setRequester(null);
map(source.getAssignedTo()).setAssignedTo(null);
map(source.getDescription()).getDetails().setDescription(null);
map(source.getSubject()).setSubject(null);
map(source.getCommentEntities()).getDetails().setNotes(null);
map(source.getAttachmentEntities()).getDetails().setAttachments(null);
map(source.getLastModified()).setLastUpdatedDate(null);
map(source.getThirdPartyTicketLink()).getDetails().getExternalTicket().setLink(null);
map(source.getExtraParameterEntities()).getDetails().getExternalTicket().setExtraProperties(null);
map(source.getStatus()).setStatus(null);
map(source.getPriority()).setPriority(null);
map(source.getTriggerName()).setTriggerName(null);
}
};
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
modelMapper.addMappings(talTicketToTicketPropertyMap);
}
Then try to use it
TicketDto convertTalTicketToSymphonyTicket(TalTicketEntity talTicket) {
TicketDto symphonyTicket = modelMapper.map(talTicket, TicketDto.class);
TicketDetailsDto ticketDetailsDto = symphonyTicket.getDetails();
if (ticketDetailsDto == null) {
but the details field is always null. which also means all the fields under it are not mapped/coppied over. FYI all fields on base TalTicket/TicketDto are coppied over.
What am I doing wrong here?