Mapstruct mapping with Ambiguous mapping methods found for mapping collection element to

2,967 views
Skip to first unread message

MileHighGuy

unread,
Oct 9, 2018, 12:36:43 PM10/9/18
to mapstruct-users
Hi,

I have a mapper entry that converts the following hash map to target hashmap:

From Map:
Map<Long, Collection<A>> from 

To Map:
Map<Long, Collection<B>> .

However in the same mapper i have two mappers defined that does the following:

public B mapFromA(A a);

public C mapFromAToC(A a);


When i build my project with the above mapping configuration, i get the following error:

Ambiguous mapping methods found for mapping collection element to 

I tried using the following annotation to let the mapper that is doing the Hashmap mapping to use the target value type but i still get the same error. 
@MapMapping(elementTargetType = A.class)

Just wanted to see if any of you in the group are aware of how to overcome this issue.

Thanks

Filip Hrisafov

unread,
Oct 9, 2018, 2:22:17 PM10/9/18
to mapstruct-users
Hey,


I am a bit confused by

    @MapMapping(elementTargetType = A.class)

You can't do such thing with the current API. There is no elementTargetType in the MapMapping.

Can you please provide us with a better example?

Cheers,
Filip
Reply all
Reply to author
Forward
0 new messages