Re: [mapstruct-users] Can't generate mapping method from non-iterable type to iterable type. - Error

2,177 views
Skip to first unread message

Christian

unread,
May 23, 2020, 5:24:35 PM5/23/20
to mapstru...@googlegroups.com

Hi Priya,

as the error said, you can't map from a non-iterable to a List. Could you give a short outline what kind of implementation you expect?

I assume you have to implement this mapping method on your own (see https://mapstruct.org/documentation/stable/reference/html/#adding-custom-methods), but in this method you can refer to other mapping methods, e. g. if your Identity has a different object that needs to be mapped you can define a mapping method that MapStruct will generate and use this in your self implemented method.


Best regards,
Christian


On 23.05.20 17:54, priiii wrote:
Hi,

I need to manipulate a list<AccountToIdentityRoleCollection> from this Identity object and frame List<PersonToBillingArrangementEdge>  and map it to List<PersonToBillingArrangementEdge> 

i tried the below,

@Mappings({

  @Mapping(target="billingArrangements", expression = "java(MapperUtil.getBillingArrangements(identity))"),

  })

  List<PersonToBillingArrangementEdge> mapPersonBillingArrangementsFromIdentity(Identity identity);


I am getting the below error 

 Can't generate mapping method from non-iterable type to iterable type.

  List<PersonToBillingArrangementEdge> mapPersonBillingArrangementsFromIdentity(Identity identity)


I have the logic of extracting the List<PersonToBillingArrangementEdge> and framing  list<AccountToIdentityRoleCollection> in getBillingArrangements method in MapperUtil class which I am importing in this Mapper. 


Can you please let me know how to resolve this issue. If this is not the rightway, then how to go about it.


Thanks

Priya

--
You received this message because you are subscribed to the Google Groups "mapstruct-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstruct-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapstruct-users/260457a6-e6ae-48fc-9685-b66d5a719cc7%40googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages