Avoid Jackson serialization on non fetched lazy objects

前端 未结 14 2019
终归单人心
终归单人心 2020-11-22 13:02

I have a simple controller that return a User object, this user have a attribute coordinates that have the hibernate property FetchType.LAZY.

When I try to get this

14条回答
  •  庸人自扰
    2020-11-22 13:18

    As of Spring 4.2 and using Spring Boot and javaconfig, registering the Hibernate4Module is now as simple as adding this to your configuration:

    @Bean
    public Module datatypeHibernateModule() {
      return new Hibernate4Module();
    }
    

    ref: https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring

提交回复
热议问题