About Orest Ivasiv

Passionate software engineer interested in different programming languages, pragmatic approaches and performance boost practices.

Java Object to Object Mapper

I’ve been using Dozer some time on the project. But, recently I have got very interesting error which motivates me to look around and try to use other Object to Object mapper.1331810342_Java

Here is the list of tools I’ve found:

  • Dozer: Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types.
  • Orika: Orika is a Java Bean mapping framework that recursively copies (among other capabilities) data from one object to another. It can be very useful when developing multi-layered applications.
  • Transmorph: Transmorph is a free java library used to convert a Java object of one type into an object of another type (with another signature, possibly parameterized).
  • EZMorph: EZMorph is simple java library for transforming an Object to another Object. It supports transformations for primitives and Objects, for multidimensional arrays and transformations with DynaBeans
  • Commons-BeanUtils: ConvertUtils -> Utility methods for converting String scalar values to objects of the specified Class, String arrays to arrays of the specified Class.
  • Commons-Lang: ArrayUtils -> Operations on arrays, primitive arrays (like int[]) and primitive wrapper arrays (like Integer[]).
  • Commons-Convert: Commons-Convert aims to provide a single library dedicated to the task of converting an object of one type to another. The first stage will focus on Object to String and String to Object conversions.
  • Morph: Morph is a Java framework that eases the internal interoperability of an application. As information flows through an application, it undergoes multiple transformations. Morph provides a standard way to implement these transformations.
  • Lorentz: Lorentz is a generic object-to-object conversion framework. It provides a simple API to convert a Java objects of one type into an object of another type.
    (seems dead)
  • Spring framework: Spring has an excellent support for PropertyEditors, that can also be used to transform Objects to/from Strings.
  • ModelMapper: ModelMapper is an intelligent object mapping framework that automatically maps objects to each other. It uses a convention based approach to map objects while providing a simple refactoring safe API for handling specific use cases.
  • OTOM: With OTOM, you can copy any data from any object to any other object. The possibilities are endless. Welcome to “Autumn”.
  • Smooks: The Smooks JavaBean Cartridge allows you to create and populate Java objects from your message data (i.e. bind data to).
  • Nomin: Nomin is a mapping engine for the Java platform transforming object trees according to declarative mapping rules. This Java mapping framework aims to reduce efforts when it’s needed to map different structures to each other.
  • Modelbridge: Modelbridge is an Eclipse plugin that lets you copy data between Java objects.
  • omapper: This project aims at providing a simple library to ease the process of mapping objects or beans from one design layer to another design layer, using annotations. One can specify mappings both in source class (Sink Annotation) and target class(Source Annotation). Supports mapping composed user class objects and array fields.
  • Moo: Moo maps an object or graph of objects to another object or set of objects while trying to stay as unintrusive as possible and easy-to-use. Moo makes it possible to create quick copies and data transfer objects.
  • OpenL Tablets: treats tables in Excel and Word files as a source of application logic. This approach may be unusual, but it has it’s own unique advantages, in particular it allows to close the gap between business world and IT world.
  • JMapper: JMapper Framework is a java bean to java bean mapper, allows you to perform the passage of data dynamically with annotations and / or XML.

Resources

 

Reference: Java Object to Object Mapper from our JCG partner Orest Ivasiv at the Knowledge Is Everything blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

10 Responses to "Java Object to Object Mapper"

  1. Gunnar says:

    Hi,

    Another alternative is MapStruct (http://mapstruct.org/, disclaimer: I’m the author if this project). It provides an approach for creating fast and type-safe bean mappers using compile-time code generation. Any feedback is highly welcome.

    –Gunnar

  2. Jeff says:

    Great article. Entered all of the above object mappers into a spreadsheet with links and other info to help determine which projects are active.

    https://docs.google.com/spreadsheet/ccc?key=0Ak1qn7j985vrdHR2cXVEWkVXZ0lWVVdyZi1TZUpqbGc&usp=sharing

  3. Séven says:

    Hi,

    I would like to share my own solution Selma http://xebia-france.github.io/selma/. This is project I made using Annotation Processor as Gunnar did, but with few differences. The mapping code is generated at compile time so you have better performance, compiler feedback, and it is refactoring proof.

    Give it a try and tell me.

  4. Rafal says:

    Hi,

    For Java version 8 based projects I would like to recommend my project: bean-cp. It relies on lambda expressions and fluent API. Bean-cp also support mapping conventions, to speed-up development. See http://erchu.github.io/bean-cp/ project home page for more details.

    Best regards,
    Rafal

  5. RaJ says:

    Hi,

    Dozer frame work was integrated in my project and would like to switch from Dozer due to performance issues as reflections based frame work.So please suggest a frame work which could work as faster as hand-coded and not reflections based.

    Thanks,
    Raj

  6. Gunnar says:

    RaJ,

    MapStruct may be exactly what you are after (disclaimer: I’m the author of this project). It generates mapping code at compile time, based on Java interface definitions. The generated code uses plain getter/setter calls and generally looks as if you had written it by hand. It doesn’t use reflection, byte code generation at runtime or similar, and the generated code is fully self-contained, i.e. there is no dependency of any sort. The code generator works on the command line (e.g. within Maven or Ant) as well as your IDE (e.g. Eclipse, IntelliJ, NetBeans) and gives you fast and helpful feedback e.g. on unmappable attributes and others. You can learn more about MapStruct in the reference documentation at http://mapstruct.org/documentation).

    Hope you find it helpful,

    Gunnar

  7. RaJ says:

    Gunnar,

    Thanks for your response and also confirm, is it open source or not?

    Thanks,
    Raj

  8. Gunnar says:

    Raj, yes, MapStruct is open source (ASF v2 license).

    Hth,

    –Gunnar

  9. Juri says:

    Hi,

    I do a lot of .Net programming and there “we” have AutoMapper. ModelMapper is somehow a port of it (as far as I’ve understood). Did anyone give it a try and likes to share some experience reports??

    I seem to understand that Dozer is the most popular one among the Java community, however I don’t really like the XML configuration approach as it is not refactoring safe. That’s why I like the convention and code-based configuration approach taken by ModelMapper.

  10. Jeff says:

    I just updated my spreadsheet with the latest release information for all the libraries mentioned in this article (including the comments).

    https://docs.google.com/spreadsheet/ccc?key=0Ak1qn7j985vrdHR2cXVEWkVXZ0lWVVdyZi1TZUpqbGc&usp=sharing

Leave a Reply


three − = 0



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close