I am new to Hibernate and JPA and am having difficulty setting up a composite key as defined below:
@Entity
@Table(name = Entity.TABLE)
@IdClass(EntityPK.class)
public class MyEntity extends Entity {
@CollectionOfElements
@JoinTable(name="items",
joinColumns = @JoinColumn(name="items"))
private List<String> items;
@Id
private Type type;
@Id
private Level level;
// plus standard constructors/getters/setters
}
public class EntityPK implements Serializable {
private Type type;
private Level level;
// plus standard constructors/getters/setters
}
When I run my dbunit tests I get the following error:
Caused by: org.hibernate.AnnotationException: A Foreign key refering com.tnt.sech.domain.management.ReasonList from com.tnt.sech.domain.management.ReasonList has the wrong number of column. should be 2
Please post if you can see where I'm going wrong!