I am having trouble using Hibernate Annotations with composite keys and field access. I'll take an example out of the annotations manal. The following classes, when initialized in the session factory are throwing an UnsupportedOperationException.
Code:
@Entity(access=AccessType.FIELD)
@IdClass(FootballerPk.class)
public class Footballer {
public String firstname;
public String lastname;
public String club;
//appropriate equals() and hashCode() implementation
}
public class FootballerPk implements Serializable {
public String firstname;
public String lastname;
//appropriate equals() and hashCode() implementation
}
The code works, of course, if I change the access attribute and add getters and setters. Is there a principled reason why this should be illegal that I am not understanding?