Hi,
I have the entities "User" and "Customer":
Code:
@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;
}
Running this (using spring), I got the following exception:
Code:
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])
I do not understand this, because I mapped the class "Customer" in @AnyMetaDef (in "User") to the constant "CST".
What am I doing wrong?
Thanks in advance for any help
Thomas