My question is how to map object contains nested object to DTO as is, not a value from the nested object, for example if there is 2 classes like this :
public class TestClass {
@Id
private String id;
@Field("field1")
private String field1;
@Field("field2")
private Long field2;
@Field("nestedClass")
private NestedClass;
//getter & setter
}
public class NestedClass {
//fields and getter and setter for it
}
DTO classes looks like :
public class TestClassDTO {
private String id;
private String field1;
private Long field2;
private NestedClassDTO ;
//getter & setter
}
public class NestedClassDTO {
//fields and getter and setter for it
}
@Mapper(componentModel = "spring", uses = {})
public interface TestClassMapper {
TestClassDTO TestClassToTestClassDTO(TestClass TestClass);
TestClass TestClassDTOToTestClass(TestClassDTO TestClassDTO);
NestedClass NestedClassDTOToNestedClass(NestedClassDTO NestedClassDTO);
NestedClassDTO NestedClassToNestedClassDTO(NestedClass NestedClass);
}
after invoking TestClassDTOToTestClass() and sending TestClassDTO contains NestedClassDTO .. it is return TestClass with null NestedClass .. is it possible to map it without write my own mapper ?
SH