我有一个使用 JPA 的 Spring Boot 项目,所以我尝试使用它们的 Id 将两个表映射到第三个表:例如,我有一个优惠券类,我有一个客户类,我想将客户 id 和优惠券 id 放入第三个表桌子。
我有优惠券:
@Entity
@Table(name = "coupons")
public class Coupon {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long coup_id;
private String title;
private String start;
private String end;
private int amount;
private String type;
private String message;
private double price;
private String image;
@ManyToMany(mappedBy = "coupons")
private List<Customer> customers;
我有客户:
@Entity
@Table(name="customers")
public class Customer {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int cust_id;
@Size(min=1,message="is required")
private String cust_name;
@Size(min = 1, message = "is required")
private String password;
@ManyToMany(cascade = { CascadeType.ALL })
@JoinTable(
name = "customer_coupon",
joinColumns = { @JoinColumn(name = "cust_id") },
inverseJoinColumns = { @JoinColumn(name = "coup_id") }
)
private List<Coupon> coupons;
我有连接表 customer_coupon:
这是我在启动项目时遇到的错误:
Caused by: org.hibernate.DuplicateMappingException: Table [coupons] contains physical column name [coup_id] referred to by multiple physical column names: [coupId], [coup_id]
我不知道它来自哪里,如果有人能帮助我,我会很高兴!
慕尼黑8549860
慕村9548890
人到中年有点甜
慕斯王
温温酱
相关分类