We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It works well for
public class MainTest { public static void main(String[] args) { ModelMapper modelMapper = new ModelMapper(); Parent p = new Parent(); p.name = "1"; Order order = new Order(); order.name = "2"; order.parent = p; OrderDTO dto = modelMapper.map(order, OrderDTO.class); System.out.println(dto.parentName); } } class Order { String name; Parent parent; } class Parent { String name; } class OrderDTO { String name; String parentName; }
but does not work for
class Order { String name; Order parent; }
The text was updated successfully, but these errors were encountered:
@tuonglx - Sorry for the lately reply... I think self reference is always complicated and not easy to handle. Maybe you can try our explicit mappinp.
If you are using ModelMapper v1.0.0 with java 8, then you can do this.
modelMapper.typeMap(Order.class, OrderDTO.class).addMapping( src -> src.getParent().getName(), (dest, value) -> dest.setParentName(value));
Or for old school style, you can try this
modelMapper.addMappings(new PropertyMap<Order.class, OrderDTO.class>() { protected void configure() { map().setParentName(source.getParent().getName()); } });
And thanks for the report! I will close this issue, and feel free to leave comment if you still have some problem.
Sorry, something went wrong.
No branches or pull requests
It works well for
but does not work for
The text was updated successfully, but these errors were encountered: