是否有我缺少的注释或者这是对休眠检索的限制?
实体:
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;
}
}
DAO:
class ADaoImpl {
public A load(Long id) {
return new A((A) session.load(A.class, id);
}
}
当我尝试加载 A 时,我得到一个
Caused by: java.lang.NullPointerException
at org.hibernate.engine.internal.StatefulPersistenceContext.getLoadedCollectionOwnerOrNull(StatefulPersistenceContext.java:853)