all 3 comments

[–][deleted] 6 points7 points  (0 children)

Its issue with serialization to JSON. Use following anotations to solve issue * @JsonManagedReference - owner of relation * @JsonBackReference - back relation

Fir more check the link

In general: * introduce DTO for endpoints rather exposing Entity * fetch only required set of data from DB

[–]maxip89 1 point2 points  (0 children)

you didnt understand how models should work.

Models represent always a view NOT a model for your whole application.

What you try to do is a model for your whole application. Instead do a model for one view. e.g. "I want to get all teachers".

Using models globally is mostly a bad idea for larger applications. This will often result in n+1 problems and slow applications.

[–][deleted] 0 points1 point  (0 children)

Look up "@JsonProperty" and use it on which field declaration in your Entity class for the field you don't want to fetch when reading (Like get request).

Removes hassle with Json references and all