I have two domain classes like these.
@Getter
@Setter
public class User {
private String name;
}
@Getter
@Setter
public class Student extends User {
private int grade;
}
And I have also two Dto classes like these.
@Getter
@SuperBuilder
public class UserDto {
private final String name;
}
@Getter
@SuperBuilder
public class StudentDto extends UserDto {
private final int grade;
}
So I made a mapper class StudentMapper which extends GenericMapper.
public interface GenericMapper<D, E> {
D toDto(E e);
E toEntity(D d);
}
@Mapper(componentModel = "spring")
public interface StudentMapper extends GenericMapper<StudentDto, Student> {
}
But I got an error while compiling Mapper.
"StudentDto does not have an accessible constructor."
What's wrong with those codes?
I want StudentDto to be unmodifiable. What will be the best way to get there with lombok and mapstruct?
You can get the source codes from here. https://github.com/jangdaewon/sandbox.lombokmapstruct