我有实体“用户”和“客户”:
@Entity
@Table(name = "USR_USER")
public class User extends PersistentObject {
[...]
@Any(metaColumn = @Column(name = "USR_OWNERTYPE"))
@AnyMetaDef(idType = "long", metaType = "string", metaValues = {
@MetaValue(targetEntity = Customer.class, value = "CST"),
@MetaValue(targetEntity = Client.class, value = "CLT") })
@JoinColumn(name = "USR_OWNERID")
private PersistentObject owner;
}
@Entity
@Table(name = "CST_CUSTOMER")
public class Customer extends PersistentObject {
@Id
@GeneratedValue
@Column(name="CST_ID")
private long id;
[...]
// @OneToMany(mappedBy = "owner")
private transient Set<User> users;
}
运行这个(使用spring),我得到了以下异常:
Caused by: org.hibernate.MappingException: Foreign key (FK35B91BB65D577CEF:USR_USER [USR_OWNERTYPE,USR_OWNERID])) must have same number of columns as the referenced primary key (CST_CUSTOMER [CST_ID])
我不明白这一点,因为我将@AnyMetaDef(在“User”中)中的“Customer”类映射到常量“CST”。
我究竟做错了什么?
提前感谢托马斯的任何帮助