Hi when I adding two list to my ListA tabell where I use Rest Api ListA, the first list have id 1 and the other list have id 2
After I execute rest api for ListB just one time and also adding data from id 2 from ListA. I get status 200 in postman with right details.
When I looking at my database I see that the FK is pointing at wrong PK from tabell ListA instead pointing at PK id 2 its pointing PK id 1 in tabell ListA.
Summary
My FK in ListB is not pointing at the right PK in tabell ListA
@MapsId
@JoinColumn(name = "listA_fk")
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private ListA listA;
@OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL, mappedBy="listA")
@JsonIgnore
private ListB ListB;
CodePudding user response:
That's what @MapsId , shared id,remove @MapsId.