i create mapping like below. How to map flat dto object properties like (street, city, etc) to nested address in domain object. When I try to I've got an error:
[ERROR] diagnostic: Unknown property "address.postalCode" in return type. @Mapping(source = "city", target = "address.city"),
@Mapper(componentModel = "spring", uses = {})
public interface CompanyMapper {
    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "street", target = "address.street"),
            @Mapping(source = "city", target = "address.city"),
            @Mapping(source = "postalCode", target = "address.postalCode"),
            @Mapping(source = "province", target = "address.province"),
    })
    DomainObject map(DtoObject dto);
And classes...
public class Address {
            private String street;
            private Integer streetNumber;
            private String city;
            private String postalCode;
            private String province;
            //getters and setters
    }
public class DomainObject {
        private String id;
        private Address address;
        //getters and setters
}
public class DtoObject {
        private String id;
        private String street;
        private String city;
        private String postalCode;
        private String province;
        //getters and setters
}
                Nesting on the target side as you are trying to use it is not supported yet. There's a feature request for this (issue #389), but we did not yet get to implementing this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With