-
Notifications
You must be signed in to change notification settings - Fork 303
bean mapping #4
Comments
I vote for dozer, since were using it very succesfully for the last 6 years now. We had very few problems with bugs. For oasp we should decide for proven solutions and do not experiment. |
I'm not a dozer fan, but I think there is no serious alternative right now. What I did not like in dozer was the XML config, but now there is a Java config (http://dozer.sourceforge.net/documentation/apimappings.html) which looks very promising for me. How about going for the Java config? |
were using both aproches. For one project we delevoped a custom adapter, which reads the config from excel and instruments dozer apis for configuration. |
I would not consider this as very successful. It has serious bugs and limits your usage. Orika looks way more promising to me. The coverage of a bean mapping framework is quite easy to test so we could give it a test and verify it. Until that I would go with dozer what we are currently using in the sample app. |
I have created a tiny shim as wrapper for bean mapping. As implementation I delegate to dozer and can add some workarounds/fixes (e.g. mapping of null values, mapping of collections, etc.). I updated our sample application to use this new module and removed all direct references to dozer from the example. This already fixed some bugs. However, generic handling is still problematic. |
This wrapper is the right way. So we choose which features we expose to the application developer. |
When it comes to bean-mappings, I just have to mention MapStruct (which I am involved in). MapStruct is an annotation processor that generates implementations for, in the simplest case, an interface that defines methods to map from Type A to B.
|
@agudian do you know orika as well? Maybe you can convince us that a code-generation approach is not causing pain in large scale projects. Orika has a IMHO smarter approach by generating the code on the fly. I have been using hibernate code generation, QueryDSL code generation, etc. in large scale projects and it is a pain! Developers update the code from version control, wait for everything to build and then figure out that they have to regenerate (maybe outside IDE with maven) and build again. This is to be avoided. How did you solve this? |
For our large scale project, we chose to not perform the source generation (wsdl2java, xjc, JPA metamodel, MapStruct) on the fly. Main reason here was also the tideous IDE integration, which sometimes does the generation automatically, sometimes not, sometimes requires manual refreshes before or after the generation, etc... Based on your comment, you know what I'm talking about. 😉 |
Andreas is completly right. If you have big object graphs to map, Dozers impact on performance becomes measureable which is a showstopper for Dozer from my point of view. As we faced very good experiences using MapStruct even in a large scaled project I vote for go on with mapstruct. |
As I wrote, please provide unit tests and then we can also add a second implementation of the same interface for the moment we can keep the technical dependency as optional until decision is finalized. |
That's not really how MapStruct works. You don't have a central mapper interface with just a method Besides the runtime-performance, this was one of the big sellings points for MapStruct in our project: you can map only between types for which you specified mapping methods. And the generator will give you warnings/erros in case some properties could not be mapped. |
|
So far nobody showed up with tests and an alternate implementation. We have do our first release with dozer. It is not perfect but works. Exchange can be done quite easily. However, I will keep the ticket open and just move to the next release. |
@oelsabba if you are looking for a way to run the same tests once with dozer and once with orika have a look here for how this can be done with JUnit: Just use something like this in your case:
|
…package for DozerBeanMapper
…st.java to run separate test methods for Orika and Dozer
…test once with OrikaBeanMapper and once with DozerBeanMapper
… Parametrized test
I have meanwhile created a test for the bean mapper that is running on Dozer. Next we will integrate (parts) of the PR from @oelsabba and provide an Orika implementation as well. Also we need to extend the test as it is only testing one use-case. |
Funny, yesterday I forked oasp4j for the first time to check what I might have to do to demonstrate the usage of MapStruct in the project... As MapStruct follows a totally different approach as dozer or orika, it can't be used as a drop-in replacement of them and it especially makes no sense in hiding it behind a common Would oasp in general be interested in such a demonstration? |
Our course it is interesting. Maybe you can convince people easier. However, I would suggest that you keep your effort low to show a single usage on a fork so in case it does not get merged you wont feel bad. That is at least why I want to go away from dozer. |
@agudian then MapStruct in the end is IMHO nothing but a code-generator. We already have CobiGen for that purpose. We can give @may-bee the challenge to write templates for CobiGen that do the same as MapStruct does :) |
Exactly, MapStruct is a code-generator. An annotation-processort, that generates code at compile-time. The comment of mine above with the manually triggered code generation is almost a year old. I could write a lot more on how we use MapStruct in our projects, for what we use those mappers and so on... But I'll see that I add a MapStruct mapper to one of the components as a showcase in a new PR first, that might illustrate things a bit better. |
See #319 |
Force locale to en_EN in order to make the tests pass
Just revisiting some issues for research... I noticed that the last update of Dozer 5.5.1 is from 22/04/2014... that is, we are relying on a 3 years old project... Do we have better experience now with alternatives and can propose a change for OASP4J? |
Orika seems to be well maintained. https://mvnrepository.com/artifact/ma.glasnost.orika/orika-core |
Btw. there seems to be fresh air going through the old lines of code of dozer: https://github.com/DozerMapper/dozer/pulse |
For bean mapping we should create a very small shim as module. We should also discuss if dozer is the right choice. Alternatives are mapstruct or orika. Dozer might be established but it has proven to be buggy.
The text was updated successfully, but these errors were encountered: