我正在为遗传数据库工作,我已经为其生成了以下实体类:
商家实体
@Entity
public class Business { ... }
Frontuser 实体
@Entity
public class Frontuser { ... }
审核实体
@Entity
@Table(name="review")
public class Review {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(unique=true, nullable=false)
private int id;
@Column(nullable=false)
private int businesshoteltravelId;
@Column(name = "frontuser_id", nullable=false)
private int frontuser_id;
@Column(name = "business_id", nullable=false)
private int business_id;
@ManyToOne
@JoinColumn(name="frontuserId", nullable=false)
private Frontuser frontuser;
@ManyToOne
@JoinColumn(name="businessId", nullable=false)
private Business business;
}
如图所示,列frontuser_id
和business_id
是其他表的外键列。列frontuserId
和businessId
是令人厌恶的(从命名约定的角度来看)。
值得注意的是,review
表实际上包含四列frontuser_id
,business_id
,frontuserId
和businessId
。
使用这些实体声明,我的应用程序无法启动以下异常:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'entityManagerFactory'
Table [review] contains physical column name [business_id] referred to by multiple physical column names: [businessId], [business_id]
我不确定为什么会出现这个错误,因为我在实体类声明中明确命名了表列。
如何使用JPA映射这些属性?