我有两个表clients和contact:
public class Contacts implements Serializable{
@Id
@GeneratedValue
private Long idContacts;
private String nomContacts;
private String prenomContacts;
private String telephone;
private String autreTelephone;
private String fax;
private String email;
private int deleted = 0;
@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name = "idClient")
private Client client;
}
我声明了一个Contact的实例:
Contacts contact = new Contacts()
如何手动设置联系人的外键我尝试了:contact.getClient().setIdClient(1)
,但不起作用。
https://stackoverflow.com/questions/50557726
复制相似问题