I have three objects: A, B, and C.
A has a one-to-many relationship with B.
B has a one-to-many relationship with C.
The classes are as follow:
public class A {
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(...)
Set<B> getBSet();
}
public class B {
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(...)
Set<C> getCSet();
}
When I used session.get(A.class, id) (session is a Hibernate object and I already had the A instance saved in the database with one set of B and 1 set of C) to get a persistent object of class A with the provided id, I got the following exception:
Apr 12, 2018 4:44:25 PM org.hibernate.event.internal.DefaultLoadEventListener onLoad
INFO: HHH000327: Error performing load command : org.hibernate.PropertyAccessException: Exception occurred inside setter of com.example.B.cSet
The setter in B is:
public void setCSet(Set<C> cSet) {
this.cSet = cSet;
...
}
I thought I already forced everything to be eagerly loaded, but somehow it didn't work the way I wanted.
Any ideas what has happened and how should I fix it?
Thank you for your time.