作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用下面的类,但给出了类似 Caused by: org.hibernate.DuplicateMappingException: Table [] contains physical column name [scheme_name] referred by multiple physical column names: [SCHEME], [schemeName] 帮我解决这个问题。
@Embeddable
public class DRollSchemesId implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@Column(name = "ROLL_NO", length = 20)
private String rollNo;
@Id
@Column(name = "SCHEME", length = 100, updatable = false, insertable = false )
private String schemeName;
public DRollSchemesId() {
}
public DRollSchemesId(String rollNo, String schemeName) {
this.rollNo = rollNo;
this.schemeName = schemeName;
}
public String getrollNo() {
return this.rollNo;
}
public void setrollNo(String rollNo) {
this.rollNo = rollNo;
}
public String getschemeName() {
return this.schemeName;
}
public void setschemeName(String schemeName) {
this.schemeName = schemeName;
}
这是实体,我正在尝试通过使用该 Embeddable 类来使用复合键。
@Entity
@Table(name = "D_ROLL_SCHEMES")
@IdClass(DRollSchemesId.class)
public class DRenewalAddonCoverages implements java.io.Serializable{
private static final long serialVersionUID = 1L;
private DRollSchemesId id;
@Id
@Column(name = "ROLL_NO", length = 20)
private String rollNo;
@Id
@Column(name = "SCHEME", length = 100, updatable = true, insertable
= true )
private String schemeName;
public DRenewalAddonCoverages(){
}
@Id
@AttributeOverrides(
{
@AttributeOverride(column = @Column(name = "ROLL_NO",
updatable = true, insertable = true), name = "rollNo"),
@AttributeOverride(column = @Column(name = "SCHEME", updatable
= true, insertable = true), name = "schemeName")
})
@EmbeddedId
public DRollSchemesId getId() {
return this.id;
}
public String getrollNo() {
return rollNo;
}
public void setrollNo(String rollNo) {
this.rollNo = rollNo;
}
public String getschemeName() {
return schemeName;
}
public void setschemeName(String schemeName) {
this.schemeName = schemeName;
}
public void setId(DRollSchemesId id) {
this.id = id;
}
}
最佳答案
尝试如下:
class DRollSchemesId implements Serializable {
private String rollNo;
private String schemeName;
}
@Entity
@Table(name = "D_ROLL_SCHEMES")
@IdClass(DRollSchemesId.class)
public class DRenewalAddonCoverages implements java.io.Serializable {
@Id
@Column(name = "ROLL_NO", length = 20)
private String rollNo;
@Id
@Column(name = "SCHEME", length = 100, updatable = true, insertable = true)
private String schemeName;
}
关于java - 组织.hibernate.DuplicateMappingException : Table contains physical column name [coverage_name] referred to by multiple physical column names:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51930214/
我正在使用下面的类,但给出了类似 Caused by: org.hibernate.DuplicateMappingException: Table [] contains physical colu
我是一名优秀的程序员,十分优秀!