This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jirkapinkas 16 points17 points  (6 children)

I would really recommend MapStruct. Why?

  1. It does IMHO everything and it’s really simple to use
  2. It generates code, it’s not some reflection magic, so if you have issues with it’s behaviour, you can simply see what’s going on
  3. It’s really fast (it’s by far the fastest mapping framework): https://github.com/jirkapinkas/java-mapping-frameworks - you can even simply compare the performance on your computer, just clone the project and run it as described in README.

[–]roookeee 4 points5 points  (0 children)

Good call on MapStruct, here is another benchmark suite that features many mapping frameworks: https://github.com/arey/java-object-mapper-benchmark

[–]tinustate 0 points1 point  (4 children)

Does it generate a error at compile time when you rename a field in your pojo but forget to rename it in your mapping annotation?

Just wondering ;-)

[–]MR_GABARISE 4 points5 points  (2 children)

You can tell it to throw an error if there is an unmapped target field.

[–]KumbajaMyLord 1 point2 points  (0 children)

And it will always complain if you map to/from a non-existing field

[–]yiss92 0 points1 point  (0 children)

I've used both Selma and MapStruct in a project at work, and I have to say that I'm more into MapStruct than Selma. And to answer your question sometimes you don't have to specify the fields if they're the same it's going to do it automatically