matches multiple source property hierarchies problem
See original GitHub issueHi, I’m using JPA(with Hibernate) and wish to convert some composite domain to view layer, So I’m using ModelMapper also.
At first, I defined some domain and DTO classes.
@Entity
public class User {
...
@Id
String id;
@OneToOne
Preference preference;
...
}
@Entity
public class Preference {
...
@Id
String id;
@OneToOne
User user;
BigDecimal money;
...
}
public class UserDto {
...
String id;
BigDecimal preferenceMoney;
...
}
then, I’ve tried to mapping DTO object instance to domain object instance.
UserDto userDto = new UserDto();
userDto.setPreferenceMoney(1000.0);
mapper.map(userDto, User.class);
this code returns error
1) The destination property User.setPreference()/Preference.setUser() matches multiple source property hierarchies:
Skipping to set user to Preference class suppress this error, but when saving data to persist returned exception that preference object instance couldn’t get user property. 😦
Is this an another case of circular reference problem? I’ve dig circular reference test cases, but I can’t find a solution.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:15 (6 by maintainers)
Top Results From Across the Web
ModelMapper: matches multiple source property hierarchies
This resolved my problem: modelMapper.getConfiguration().setAmbiguityIgnored(true);.
Read more >destination property setId() matches multiple source ... - GitHub
I am using ModelMapper with all default settings. I tried STRICT and the problem goes away, but that causes other problems, so I...
Read more >Configuration - ModelMapper
The Loose matching strategy allows for source properties to be loosely matched to destination properties by requiring that only the last destination property...
Read more >the destination property matches multiple source property ...
Multiple PropertyMaps may be added for the same source and destination types, so long as only one mapping is defined for each destination...
Read more >ConfigurationException: ModelMapper configuration errors:
I'm trying to use ModelMapper in a grails project. Its works and I need to skip certain field while mapping from Domain to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);working for you? And could you please provide more detail about your source/destination class. Thanks.Anyone figure this out yet? 👁️