Is there an annotation I'm missing or is this a limitation to hibernate retrieval?
Entities:
class A {
Long id;
Set<B> b;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "A_B", joinColumns = @JoinColumn(name = "A_ID"), inverseJoinColumns = @JoinColumn(name = "B_ID")
public Set<B> getBs() {
return b;
}
}
class B {
Long id;
Set<C> c;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "B_C", joinColumns = @JoinColumn(name = "B_ID"), inverseJoinColumns = @JoinColumn(name = "C_ID")
public Set<C> getCs() {
return C;
}
}
DAOs:
class ADaoImpl {
public A load(Long id) {
return new A((A) session.load(A.class, id);
}
}
When I attempt to load an A, I get a
Caused by: java.lang.NullPointerException
at org.hibernate.engine.internal.StatefulPersistenceContext.getLoadedCollectionOwnerOrNull(StatefulPersistenceContext.java:853)
I had an issue very similar to this were i had nested sets, and the hashCode methods for each showed up in the stack trace. In the hashCode methods, they referred to each other, so I removed the reference to each object in the hashcode methods, and I no longer got this exceptions
I think it is not the complete exception right?
Where is the setter in class A? The b collection in class A is friendly scoped then hibernate will not be able to write/inject it's value. The same goes for the C collection in class B.
Please, copy your hibernate.xml and any other configuration class here. The hibernate/java version are important too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With