我在Spring Web MVC中使用Spring Data JPA和REST Controller有一个解决方案.持久性提供程序是Hibernate.
持久层是使用Spring Repositories构建的,在de REST Controller和存储库之间存在一个服务层:
Entity <--> Repository <--> Service <--> Controller
Run Code Online (Sandbox Code Playgroud)
在实体级别,我有@OneToMany字段,其中FetchType = LAZY.
当REST控制器进行序列化时,会进行提取,但在某些情况下这是不合需要的.
我已经尝试使用@JSONInclude Jackson注释,序列化仍然存在.
有人可以用经证实的解决方案帮助我吗?