I was following the discussions and mapping frameworks from time to time and was trying to figure out if I need one already? Are there any frameworks to do the job? Are there any frameworks to do the job right? Is it worth to look for such framework?
- If your task is simple - then why another framework in your classpath?
- If your objects are complex - will the framework do the job? You know the logic behind, so it might happen that you will complete the task faster than finding, configuring, running and testing a new framework;
- For one-to-one mapping and cloning (same source type, same target type) maybe apache commons beanutils is enough?
- Boring daily mapping? Yeah, maybe the mapper will help to make your life more interesting!
What are the requirements?
Let's make some requirements for a mapping framework. These will eliminate many of already existing in the market.
- DTO to JPA (or other DTO, does not matter too much) - meaning that JPA entity will not be exposed to a public world;
- Compile time. Why? Do you really want a runtime bean resolving, reflection, etc? Then think about performance before choosing the right framework;
- Annotation based. Ok, annotation based and compile time requirements are little bit too much, because annotation is used only to generate a code for you. But if it is easy to use - why not?
There is a great article covering the existing frameworks: Java Object to Object Mapper
The majority of these frameworks do not have annotation based configuration except Dozer. However Dozer does not fly well according the performance comparision Dozer vs Orika vs Manual. So I excluded this framework as well.
I will try to cover them in Part 2!
Senior software engineer, software architect for java enterprise based solutions