首先多对的一方的PO中一定要注意 要初始化 关联的一方
@ManyToOne
//@JoinColumn(name = "customer_id")不加也会自动生成的
private Customer customer = new Customer();
然后在前台拿到CUSTOMER的ID以后
Items it = new Items();
it.getCustomer().setId(1);
tx.begin();
session.persist(it);
tx.commit();