Jackson/Hibernate, meta get methods and serialization

前端 未结 2 2062
北恋
北恋 2020-12-02 03:02

We have lot of hibernate entity classes with nested relationships. I\'m trying to find best way to convert given entity to equivalent json format.

I know about JsonI

2条回答
  •  感动是毒
    2020-12-02 03:17

    What I usually do is map Entities to DTOs manually, or with the help of tools such as MapStruct.
    This will give you maximum flexibility, with a bit of overhead at the beginning, unfortunately.
    Over time however, you'll see it was worth it.

    Jackson, GSON, and other serialization tools are obviously limited in what they can do out-of-the-box, and this kind of customization requires a bit too much work, imho, while also being difficult to understand and maintain.

    Keep it simple.

提交回复
热议问题