I have a list of string in my DTO, i want to map it into a list of object, in the mapper i used the service to get the object by this string, but i have the below error
Can't map property "java.util.List<java.lang.String> customers" to "java.util.List<com.softilys.soyouz.domain.Customer> customers".
Consider to declare/implement a mapping method: "java.util.List<com.softilys.soyouz.domain.Customer> map(java.util.List<java.lang.String> value)".
public class FirstDomain implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String id;
private String description;
private List<Customer> customers;
}
public class FirstDomainDTO {
private String id;
private String description;
private List<String> customers;
}
@Mapper(uses = { CustomerService.class })
public interface FirstDomainMapper extends EntityMapper<FirstDomainDTO, FirstDomain> {
@Mapping(source = "customers", target = "customers")
FirstDomainDTO toDto(FirstDomain firstDomain);
@Mapping(source = "customers", target = "customers")
FirstDomain toEntity(FirstDomainDTO firstDomainDTO);
default String fromCustomer(Customer customer) {
return customer == null ? null : customer.getCode();
}
}