Using Hibernate 3.2 and JPA Annotations, I'm able to map a Set but getting the following exception when I change the same mapping to a List (and adding an @OrderBy).
Code:
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.xxx.RelationTarget.target
Here's the OneToMany
Code:
@OneToMany(targetEntity = com.xxx.RelationTarget.class, mappedBy = "relation", cascade = {CascadeType.REMOVE,
CascadeType.PERSIST })
@OrderBy("sequence")
@org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
public List<RelationTarget> getTargets() {
return _relationTargets;
}
Here's the ManyToOne (that the exception is complaining about)
Code:
@ManyToOne(targetEntity = com.xxx.Relation.class, cascade = CascadeType.PERSIST)
@JoinColumn(name = "relationid", insertable = false, updatable = false)
public Relation getRelation() {
return _id.getRelation();
}
Insertable and Updatable are set to false because this class uses an @Embeddable id.
Code:
@Id
protected RelationTargetPK getId() {
return _id;
}
Here's the @embeddable PK class mapping
Code:
@ManyToOne(targetEntity = com.hli.redhat.value.Relation.class, cascade = CascadeType.PERSIST)
@JoinColumn(name = "relationid")
public Relation getRelation() {
return _relation;
}
Thanks!