我有2个表客户和客户历史. customhistory有外键customerId,它引用了客户的customerId.在由JPA生成的实体中,我在customerhistory类中有一个customer对象,而我想在consumerhistory表中只保存customerId
我得到了正确的customerId,但是当我想保存属性customerId时,我只有客户的对象,但是我自己生成的实体类中没有customerId
@Entity
public class Customerhistory implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int primarykeyId;
//bi-directional many-to-one association to Customer
@ManyToOne
@JoinColumn(name="CustomerId")
private Customer customer;
如上所示,我在实体customerHistory中没有customerId.怎么保存?