Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapstruct : Ambiguous mapping methods found for mapping collection element

Tags:

java

mapstruct

I have two methods for mapping entity to domain.

RDomain entityToDomain(REntity rEntity)

/*
this method ignores some of the fields in the domain.
*/
RDomain entityToDomainLight(REntity rEntity)

I'm getting Ambiguous mapping methods found for mapping collection element when I try to define mapping method for List of entities to domains.

List<RDomain> entitiesToDomains(List<REntity> rEntities)

Is there a way to define which method to use for mapping collection of objects

like image 776
santhosh Avatar asked Mar 15 '18 15:03

santhosh


1 Answers

As @Filip suggested, it is better to do something like that :

RDomain entityToDomain(REntity rEntity)

@Named(value = "useMe")
RDomain entityToDomainLight(REntity rEntity)

@IterableMapping(qualifiedByName = "useMe")
List<RDomain> entitiesToDomains(List<REntity> rEntities)
like image 184
ihebiheb Avatar answered Nov 02 '22 16:11

ihebiheb