Skip to content
Advertisement

is there any way to fetch data from many to many tables using spring without infinite json format?

user entity

JavaScript

board entity

JavaScript

When I try to fetch data using findAll method I get infinite json object.

For example when I fetch users I have set of boards inside it I have set of users and inside it I have set of boards… etc.

How can I fetch user with his boards and boards with its users ?

Advertisement

Answer

You can use @JsonBackReference in the class where you don’t want to get the linked object.

So, if I’ve not missunderstood, one user has many boards, and a board owns to an user or many, so fetching one user you get an infinite recursion.

So into Board class you have to do:

JavaScript

And then, the object will not be infinite.

Also you can check this article.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement