Thanks for your reply. OK, I guess I was a bit vague regarding the IdClass. A.AId is as you guessed an inner class. But since you mention problems with Hibernate and inner classes I moved it in another public class:
Code:
@Entity
@IdClass(AId.class)
public class A {
@Id
@Column(unique = true)
private long akey;
@Id
private long anotherkey;
// getter and setter follow
}
public class AId implements Serializable {
public long akey;
public long anotherkey;
}
Class B remains untouched and the error from my first post still exists. One slight correction though: The example from my first post was untested; the error message is
Code:
Caused by: org.hibernate.AnnotationException: referencedColumnNames(akey) of pkg.B.a referencing pkg.A not mapped to a single property
Of course the word package itself is not a valid package name, so I now chose pkg.
When I remove the @ManyToOne constraint anything seems to work so the primary key of class A should not be an issue (but well, you never know).
If anybody has the time to try this example, my table definitions are as follows:
Code:
CREATE TABLE a ( akey BIGINT UNIQUE, anotherkey BIGINT, PRIMARY KEY(akey, anotherkey) );
CREATE TABLE b ( id BIGINT PRIMARY KEY, akey BIGINT, FOREIGN KEY(akey) REFERENCES a(akey) );
Greetings
mK