Jackson bidirectional relationship (One-to-many) not working

后端 未结 3 1348
半阙折子戏
半阙折子戏 2021-01-14 07:48

I\'m using Spring(xml+annotations), Hibernate(annotations) in this web service project. The database relationship diagram, models, expected and actual output are given below

3条回答
  •  一向
    一向 (楼主)
    2021-01-14 07:55

    Here is a bit lengthy approach. But needs some design modifications in your app. I had a similar problem and I created separate pojos for every entity classes.

    In service layer I use these pojos instead of the entity objects as parameters and I use appropriate getters/setters to set/get the properties to/from entity classes. In this way you can get/set the properties you want to and avoid unwanted ones. However I implemented additional methods in DAO layer to get the related entities. This is very lengthy approach but solved the problem for me.

提交回复
热议问题