Hi,
I have a question about detaching objects after issuing query with JOIN FETCH. Let's say I have two classes:
public class A { @ManyToOne B bClass } public class B { @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) List<A> aClasses; }
Now, I want to fetch all B classes with all A classes skipping lazy loading:
select b from B b join fetch b.aClasses
After closing entity manager, B classes became detached but without A classes and because EM is closed, B.aClasses is always null.
I thought, that after join fetch and CascadeType.DETACH list of A classes should be accessible from B, or am I wrong?