S
S
supervtb2018-01-31 19:42:51
Java
supervtb, 2018-01-31 19:42:51

Looping on @onetomany?

Good evening. There are two entities, store and bonus. And a one-to-many relationship. T e store has a lot of bonuses. Requires bi-directional communication. That is, one url gives an array of bonuses (each bonus object contains a store object), and another url gives an array of stores (each store contains an array of bonuses). The problem is looping.
For the bonus, I set @JsonBackReference, and for the store, respectively, @JsonManagedReference.
The looping is gone, when the list of stores is displayed, their bonuses are also displayed, and when the list of bonuses is displayed, the stores are not displayed.
The question is how to implement the withdrawal of stores?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
supervtb, 2018-01-31
@supervtb

solved by @JsonIgnoreProperties(value = "store", allowSetters = true)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL)
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question