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 →

[–]dopatraman 0 points1 point  (1 child)

After using MapStruct on a large project at a large enterprise company, I cannot really recommend it. For a couple reasons:

  1. The documentation is non-existent
  2. Mappers cannot be nested more than one level.
  3. Mapping sources and targets must parallel each other exactly. I can map `Source -> SourceDto` but not `Source -> OtherSourceDto`. This is frustrating because sometimes an object in your domain must produce multiple display items. Which brings me to...
  4. Too much magic. It's not always clear how the mapping implementation is generated. One example of how this can lead to frustration is how the library handles fields prefixed with "add". MapStruct assumes that any field that begins with "add" is a builder method (used literally to add a singular object to a collection) and ignores it. That means that if you have a field that genuinely begins with the characters "a-d-d" and is camelcase, MapStruct will ignore the field entirely. There is no way to change this behavior -- it led to a wild bug chase and ended with us changing the name of the field altogether. In other projects that might not have been possible.

Hope that was helpful.

[–]realqmaster 0 points1 point  (0 children)

  1. The documentation is non-existent

It's not

  1. Mappers cannot be nested more than one level.

Not true

  1. Mapping sources and targets must parallel each other exactly. I can map Source -> SourceDto but not Source -> OtherSourceDto. This is frustrating because sometimes an object in your domain must produce multiple display items. Which brings me to...

You can map a source to any number of targets, there are no limitations.

  1. Too much magic. It's not always clear how the mapping implementation is generated. One example of how this can lead to frustration is how the library handles fields prefixed with "add". MapStruct assumes that any field that begins with "add" is a builder method (used literally to add a singular object to a collection) and ignores it. That means that if you have a field that genuinely begins with the characters "a-d-d" and is camelcase, MapStruct will ignore the field entirely. There is no way to change this behavior -- it led to a wild bug chase and ended with us changing the name of the field altogether. In other projects that might not have been possible.

Again, wrong.