I'm working with mongodb so I'm decoupling entities from presentation layer creating DTOs (with hibernate-validator annotations).
public abstract class UserDTO {
private String id;
@NotNull
protected String firstName;
@NotNull
protected String lastName;
protected UserType type;
protected ContactInfoDTO contact;
protected List<ResumeDTO> resumes;
public UserDTO(){}
//...
I'm trying to retrive from db this concrete class
public class UserType1DTO extends UserDTO {
private CompanyDTO company;
public UserType1DTO(){
super();
}
public UserType1DTO(String firstName, String lastName, ContactInfoDTO contact, CompanyDTO company) {
super(UserType.type1, firstName, lastName, contact);
this.company = company;
}
/...
Like this:
return mapper.map((UserType1) entity,UserType1DTO.class);
And I get this error about not being able to instanciate ResumeDTO
Failed to instantiate instance of destination *.dto.ResumeDTO. Ensure that *.dto.ResumeDTO has a non-private no-argument constructor.
ResumeDTO is similar to UserDTO, is an abstract class and has concrete classes for each user type. All they have constructors with no arguments. What is the problem?