BO <=> DTO mapper in Java

I am currently in my application, manually matching DTOs with BO (and vice versa). However, this approach is inconvenient and awkward.

Is there a good match between the two?

My requirements follow:

  • Convert JPA proxy to identifiers should be supported (DTO should not directly refer to another DTO). Or this functionality should be easily implemented.
  • There should be an annotation based on the content of the configuration
  • Soft criteria: must allow matching of several DTOs with one object (and vice versa)

Thanks for any suggestions.

+4
source share
3 answers

Regarding object matching, I would recommend

Also see this SO answer. It has a more or less complete list of Java Object mappers: fooobar.com/questions/33896 / ...

3 I suggested it seemed more attractive to me. I think that they all fulfill the requirements that you ask.

+8
source

Well, I know this thread is a bit outdated, and I'm sure @miguelcobain's answer is great.

Personnaly, I would recommend using Orika for a runtime system. It is strong and uses byte-code generation at runtime, so matching is handled by the generated code, and not always using the Reflection API. The other libraries listed always use complex configurations, not conventions.

The second solution and the best, I think, will use Selma . This small library does the job for you, but instead of processing the display at run time, it generates matching code at compile time using the annotation processor. Thus, the compiler will increase display errors, this is refactoring proof, and you can see the generated code.

I hope you try.

+5
source

I suggest you try the JMapper Framework .
This is java bean for java bean mapper, it allows you to dynamically traverse data using annotations and / or XML. With JMapper you can:
create and enrich targets
apply certain logic to the display
automatically manage XML file
realize the relations 1 - N and N - 1

implement explicit conversions
apply legacy configurations

+1
source

All Articles