Java object to object mapping - which framework to choose? - Part 2

We've started a discussion on current mapping frameworks in Part 1. Selection was minimized to Selma and MapStruct. So which one to choose if I do not want to do the job myself?

Selma and MapStruct works well when initial learning curve passed how to configure a mapper. There might be the personal preference which one to choose. More customizations come with Mapstruct. Generated code might be more readable in MapStruct, however they both might generate duplicated code when mapping from Object to a simple entity in case Object has multiple properties mapped.

Simple comparison

Subject/Feature Selma MapStruct
Define mapping once ok using @InheritInverseConfiguration does not work in more complex scenarios (at the given time of writing the blog entry)
Ease to define the mapping yes needs a good initial learning curve
Customizations minimal advanced. Many places may be customized
Generated code with duplications, readability might be improved with duplications, readability is better than Selma
Annotation usage class level method level


I think both projects are great and it's up to you to decide which one you would like to use in your project. There is always another option - do it yourself :) Currently I am using Selma. Happy so far :)


Photographs by Louis K..


Senior software engineer, software architect for java enterprise based solutions