Background null string is passed to the front end of characters or JSON parse error --SyntaxError: JSON.parse: unterminated string literal at line 1 column 9018638 of the JSON data

The first case:

The second case:

Question:
two tables bidirectional many, many time. In response to the background to make this error
analysis: two-way relationship, when generate json is to call each other, ignore each other need to have one of the
functions to be performed when one of the parties can be found, the multi-turn, to find a party. So F12- view the response to the foreground network - find a post request, and then view and response parameters will find that argument is no problem, and the response will be reported more errors. Click json data into the view you will find a lot of data, the response into an infinite loop. (One of the parties to find, to find a lot, then turn and go to multi-party find a lot, and finally went to cycle)
to address:
you can in a two-way configuration @JsonIgnore on which either party associated with this field configuration of the two parties.
Examples:
the document is a combination of relationships. Also it is known as a strong polymerization. (Two-way-to-many, many-to).
Both can not abandon the other. So you want to configure the strongest cascade (cascade = CascadeType.ALL), but also orphans delete (orphanRemoval = true). There are: many due to poor performance, so the party to give up to maintain the relationship, make multi-party maintenance (mappedBy = "one field")
Examples  

Purchase orders and purchase details // foreign key
the @ManyToOne (= to FetchType.LAZY FETCH, to false = optional)
@JoinColumn (name = "bill_id") // PO table foreign key
@JsonIgnore // generated when json ignore this property
private Purchasebill billId;

Documents purchase details:

// generally use a combination of relationship List (purchase orders and purchase detail list is a combination of relationship: bi-directional many-to-many)
@OneToMany (Cascade = CascadeType.ALL, the mappedBy = "BILLID", FETCH = FetchType.LAZY, orphanRemoval = to true)
Private List <Purchasebillitem> = new new items the ArrayList <Purchasebillitem> ();
 

 

Guess you like

Origin www.cnblogs.com/2019wxw/p/10989817.html