Witajcie,
mam dwie encje
@Entity
@Data
public class House {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
private String name;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "address_id")
private PostalAddress address;
}
oraz
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PostalAddress {
@Id
@GeneratedValue( strategy = IDENTITY )
private Long id;
@NotNull
@Column(length = 100, nullable = false)
private String addressLocality;
@NotNull
@Column(length = 6, nullable = false)
private String postalCode;
@NotNull
@Column(length = 100, nullable = false)
private String streetAddress;
}
stworzyłem formularz edycji i controller
@RequestMapping(value="/edit", method = RequestMethod.POST)
public String update(@ModelAttribute("house/show") House house) {
houseRepository.save(house);
return "redirect:/house/list";
}
i teraz problem jest taki, że leci UPDATE do tabeli house i INSERT do table postal_address. Napisałem po prostu save(house) bo ustawiłem EAGER i cascade.ALL ale to jest aż tak jednolinijkowo jednak nie jest :(