I have the below structure. The properties from my subclass are not getting copied to my DTO.
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
class BaseClass
{
private Integer baseProperty1;
private Integer baseProperty2;
//getters & setters
}
class SubClass extends BaseClass
{
private Integer subProperty1;
private Integer subProperty2;
//getters & setters
}
class BaseSubDTO
{
private Integer baseProperty1;
private Integer baseProperty2;
private Integer subProperty1;
private Integer subProperty2;
//getters & setters
}
class BaseClassService
{
public BaseClass find()
{
return baseClassRepository.findById(101);
}
}
class BaseClassController
{
public BaseSubDTO find()
{
return mapper.toDTO(baseClassService.find());
}
}
@Mapper(componentModel = "spring")
public interface DTOMapper
{
BaseSubDTO toDTO(final BaseClass entity);
}
The line:
return mapper.toDTO(baseClassService.find());
in the controller does not map the subclass properties subProperty1, subProperty2 to my BaseSubDTO.
How can the subclass properties be mapped into the DTO?