I have a JPA object Propertythat has children (multiple Rateand multiple Reservation). In my JavaScript application, I pull JSONthrough REST {property:{rates:[...], reservations[...]}. Rates and reservations are very detailed, so when I publish a property update (for example, a name change), I remove the rates and reservations from the payload JSON POST. I was hoping that Hibernate would simply ignore the missing keys, but alas, it would remove all the children in the rescue. How do I tell Hibernate to ignore them if they are not?
@Entity
public class Property {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
String name;
@OneToMany(mappedBy = "property", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
@JsonManagedReference
private Set<SeasonRate> rates = new HashSet<>();
@OneToMany(mappedBy = "property", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
private Set<Reservation> reservations = new HashSet<>();
}
Ps: , , , - , . , , , CASCADE = UPDATE? , .