Mapping options
by Ania Pietras
Why to use mappers?
- default settings -> less coding
- ‘global’ settings for handling NULLS, empty String ect.
- Simple conversions handling (lists, enums, different numeric types) ‘out of
the box’
- Centralization of mapping configuration in application
Available options
Source: http://stackoverflow.com/questions/1432764/any-tool-for-java-object-to-object-mapping/1432956
● Transmorph
● EZMorph
● Commons-BeanUtils
● Commons-Lang
● Commons-Convert
● Morph
● Lorentz
● Dozer
● ModelMapper
● OTOM
● Smooks
● MapStruct
● Orika
● JMapper
Available options
Library Dozer Orika JMapper
Version 5.5.1 1.4.6 1.4.2
Last release 04/2014 05/2015 09/2015
Configuration XML, annotation
(beta), JavaConfig
JavaConfig annotation, XML
Enum<>String yes yes no
Collections yes, + Map<>Pojo yes yes
Custom mappers yes, class/field yes, class/field yes, class/field
Dozer vs Orika vs JMapper
Dozer
● Reflection based (==slowly)
● Mapping from map to Object
● Develop since 2006r.
● Most popular
● Not actively maintained (152
issues on GitHub)
● stackOverflow: 1519 result
XML
ANNOTATION
JavaConfig
Orika
- Generates bytecode during first
mapping (first time is slow, then
faster)
- 27 open issues on GH
- Last commit 2 months ago
- stackOverflow: 211 results
- Developed since 2012
JavaConfig
Jmapper
- Generates bytecode during
application startup
- Last commit one month old
- 5 open issues on GH
- Dynamic converter declaration
(code snippets, including xml)
- Field mapping 1:n and n:1
- Support for flattening and
encapsulation
- StackOverflow: 19 results
- Developed since 2013
@GlobalJMap
ANNOTATIONS
XML

Mapping in Java Options

  • 1.
  • 2.
    Why to usemappers? - default settings -> less coding - ‘global’ settings for handling NULLS, empty String ect. - Simple conversions handling (lists, enums, different numeric types) ‘out of the box’ - Centralization of mapping configuration in application
  • 3.
    Available options Source: http://stackoverflow.com/questions/1432764/any-tool-for-java-object-to-object-mapping/1432956 ●Transmorph ● EZMorph ● Commons-BeanUtils ● Commons-Lang ● Commons-Convert ● Morph ● Lorentz ● Dozer ● ModelMapper ● OTOM ● Smooks ● MapStruct ● Orika ● JMapper
  • 4.
    Available options Library DozerOrika JMapper Version 5.5.1 1.4.6 1.4.2 Last release 04/2014 05/2015 09/2015 Configuration XML, annotation (beta), JavaConfig JavaConfig annotation, XML Enum<>String yes yes no Collections yes, + Map<>Pojo yes yes Custom mappers yes, class/field yes, class/field yes, class/field
  • 5.
    Dozer vs Orikavs JMapper
  • 6.
    Dozer ● Reflection based(==slowly) ● Mapping from map to Object ● Develop since 2006r. ● Most popular ● Not actively maintained (152 issues on GitHub) ● stackOverflow: 1519 result XML ANNOTATION JavaConfig
  • 7.
    Orika - Generates bytecodeduring first mapping (first time is slow, then faster) - 27 open issues on GH - Last commit 2 months ago - stackOverflow: 211 results - Developed since 2012 JavaConfig
  • 8.
    Jmapper - Generates bytecodeduring application startup - Last commit one month old - 5 open issues on GH - Dynamic converter declaration (code snippets, including xml) - Field mapping 1:n and n:1 - Support for flattening and encapsulation - StackOverflow: 19 results - Developed since 2013 @GlobalJMap ANNOTATIONS XML