【问题标题】:Json ignore collections in entitiesJson 忽略实体中的集合
【发布时间】:2014-12-02 21:02:41
【问题描述】:

我使用@JsonIgnore 忽略我的实体中的一些集合,这些集合作为json 元素在ajax 中发送。

为了生成映射类,我使用 hibernate tools

我的问题是我经常更改我的数据库架构,所以当我再次生成实体时我失去了我的 @JsonIgnore 注释。

那么有没有解决方案可以自动添加它们或将它们添加到单独的文件中?

【问题讨论】:

    标签: java json spring hibernate


    【解决方案1】:

    您可以dynamically add annotations at runtime

    1. 您需要添加一个带有@PostConstruct init 方法的Spring Bean。

    2. 在 init 方法中,您可以将实体动态添加到要忽略的实体类属性中。

    【讨论】:

      猜你喜欢
      • 2019-05-18
      • 2021-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 1970-01-01
      • 2021-08-05
      • 2021-11-22
      相关资源
      最近更新 更多