那么, 在阅读了几乎所有帖子后,我决定发布我的问题,因为我无法修复它。
B类有一个主键(2个字段)
@Entity
public class ClassA implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private ClassAPK id;
//bi-directional many-to-one association to ClassB
@OneToMany(mappedBy="classA")
private Set<ClassB> classB;
B类
@Entity
public class ClassB implements Serializable {
private static final long serialVersionUID = 1L;
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name = "ID")),
@AttributeOverride(name = "cod", column = @Column(name = "cod")),
@AttributeOverride(name = "year", column = @Column(name = "year")),
@AttributeOverride(name = "month", column = @Column(name = "month")) })
@EmbeddedId
private ClassBPK id;
// bi-directional many-to-one association to ClassA
@ManyToOne
@JoinColumns({
@JoinColumn(name = "id", referencedColumnName="ID")
})
private ClassA classA;
@Embeddable
public class ClassBPK implements Serializable {
//default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;
@Column(name="ID")
private long id;
private int day;
public ClassBPK() {
}
有什么建议吗? 感谢