Qasim Lodhi
Sep 6, 2018 · 1 min read

Lombok is not mapping, it’s the MapStruct in this example that’s doing the mapping of POJOs. There can be many ways to achieve this but I think the most appropriate one is to use @ignore annotation. From MapStruct documentation: @Mapping(target = “fish.name”, ignore = true)

The example only says target but maybe this can be used with source as well. If not, then using it on target will work too since you don’t want “id” from source to be mapped to “id” in target, so if that’s ignored in target, the mapping shouldn’t happen. Other ways are don’t have id in target or have it by different name and don’t map it then MapStruct will ignore it anyway.

    Qasim Lodhi

    Written by