'MapStruct - mapping nested List<String>

How can I use MapStruct to map nested List?

Here is my entity class:

public class ChannelEntity {

    @ElementCollection(fetch = FetchType.EAGER)
    @CollectionTable
    List<String> loggedUsers = new ArrayList<>();
...

}

I'd like to map it to:

public class Channel {
    
     List<String> loggedUsers = new ArrayList<>();
...
}

For now my mapper looks like:

@Mapper(componentModel = "cdi")
public interface JpaPersistenceChannelMapper {

    ChannelEntity toEntity(Channel channel);
    Channel toDomain(ChannelEntity channelEntity);
}

But it maps only 'normal' properties like Long, Integer etc., but it avoids nested List.



Solution 1:[1]

I found a problem. I need to have getters and setters in both classes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vicardo