我正在使用带有 spring-boot-starter-data-jpa 的 Spring-Boot 1.5.10。我有一个临时表和一个生产表,它们的结构相同,只是表名不同。列是:
- compKey1
- compKey2
- compKey3
- 可乐
- col_B
- col_c
我收到以下错误:
引起:org.hibernate.AnnotationException:没有为实体指定标识符:com.foo.bar.StagingTbl
我有一个复合主键,类定义为:
@Embeddable
public class MyId implements Serializable {
private static final long serialVersionUID = -99999999L;
protected String compKey1;
protected String compKey2;
protected String compKey3;
// setters/getters
}
my Abstract class:
@MappedSuperclass
public abstract class MyAbstractClass implements Serializable {
protected static final long serialVersionUID = 7749572933971565230L;
protected MyId myId;
protected int col_A;
protected Date col_B;
protected String col_C
public MyAbstractClass (String compKey1, String compKey2, String compKey3) {
super();
this.myId = new MyId(compKey1, compKey2, compKey3);
}
@EmbeddedId
public MyId myId() {
return myId;
}
public void setMyId(MyId myId) {
this.myId= myId;
}
// getters/setters for other properties
}
我的具体课程:
@Entity
@Table(name = "STG_TABLE" , schema="MYSCEMA")
public class StagingTbl extends MyAbstractClass implements Serializable {
}
标识符应该来自我正在扩展的 MyAbstractClass。我显然错过了一些愚蠢的事情。提前致谢。