Java mapping: Selma vs MapStruct

JackDev picture JackDev · Jan 14, 2016 · Viewed 21.9k times · Source

Currently there are two main popular Java Object to Object mapping frameworks that supersede Dozer (http://dozer.sourceforge.net/documentation/mappings.html), they are:

  1. Selma - http://www.selma-java.org/
  2. MapStruct - http://mapstruct.org/

With the exception of this page (http://vytas.io/blog/java/java-object-to-object-mapping-which-framework-to-choose-part-2/) I haven't been able to find much online regarding which framework is better than the other, or under what circumstances they are better. Wondering if anyone you can shed some light on this. In terms of functionality based on the documents, they seem to be doing the same thing.

Answer

Gunnar picture Gunnar · Jan 14, 2016

(Original author of MapStruct here, so naturally I am biased)

Indeed, both projects are based on the same general idea of generating mapping code at compile time; I recommend you MapStruct for the following reasons:

  • Proven and stable codebase: MapStruct is the older of the two, coming up with the idea of mapping generation originally. It has been enhanced and polished over quite a long time, based on real-world feedback from usage in many different projects; We released the stable 1.0 Final last year
  • Larger developer and user community as per the number of committers (MapStruct, Selma) and user questions (MapStruct, Selma)
  • Feature-rich (Some things supported in MapStruct I didn't find (to the same extend) in the Selma docs):
  • Eclipse plug-in avaible: Still work in progress, but its quickfixes and auto-completions are already very helpful when designing mapper interfaces
  • IntelliJ plug-in: helps when editing mapper interfaces via auto-completion, go to referenced properties, refactoring support etc.