You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mapper cannot be applied when we have a member inner class (Address) inside MetaAddress:
I want to map com.x.Address to com.y.MetaAddress.Address :
package com.x;
@Getter
@Setter
public class Address{
private String id;
private Long streetNumber;
private String streetNumberComplement;
private String streetType;
private String streetName;
}
package com.y;
@Data
public class MetaAddress {
Address address;
long complementCount;
boolean isRaCallRecommended;
@Getter
@Setter
public class Address{
private String id;
private Long streetNumber;
private String streetNumberComplement;
private String streetType;
private String streetName;
}}
This is the mapper :
@Component
public class GenericMapper {
private final MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
public MetaAddress.Address convertAddressToDto(Address address){
mapperFactory.classMap(Address.class, MetaAddress.Address.class);
return mapperFactory.getMapperFacade().map(address, MetaAddress.Address.class);
}
}
The error received :
while attempting to generate ObjectFactory using constructor 'public com.y.MetaAddress$Address(com.y.MetaAddress)', an automatic mapping of the source type ('Address') to this constructor call could not be determined. Please register a custom ObjectFactory implementation which is able to create an instance of 'Address' from an instance of 'Address'.
The text was updated successfully, but these errors were encountered:
wija-2015
changed the title
Mapping Member inner class from another simple class
Mapping Member inner class from another simple class not working
Jan 31, 2023
The mapper cannot be applied when we have a member inner class (Address) inside MetaAddress:
I want to map com.x.Address to com.y.MetaAddress.Address :
This is the mapper :
The error received :
The text was updated successfully, but these errors were encountered: