Jackson triggering JPA Lazy Fetching on serialization

前端 未结 2 1736
再見小時候
再見小時候 2021-01-01 22:20

We have a back-end component that exposes database (PostgreSQL) data via JPA to RESTful API.

The problem is that when sending a JPA entity as a REST response, I can

2条回答
  •  庸人自扰
    2021-01-01 22:49

    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List children = new ArrayList<>();
    

    Just try adding the fetch property to the field you want not to be eagerly fetched

提交回复
热议问题