Good afternoon!
Maple Hiberneyt class that contains a collection of objects of another class. It looks like this
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") @Fetch(FetchMode.JOIN) private List<Action> actions;
on the other side
@ManyToOne() private Manager owner;
Next, I do a Criterion request to get all the container objects (that is, class = Manager). And I see in the logs: Hibernette first receives container objects, and then makes special-selects for each of them to get nested collections, that is, it outputs to the select database ... where id = container_id for each container found earlier. It seems to me not very optimal. Isn't it better to take everything together by one join? This raises the question: is it possible to force Hibernate to take all nested collections with one join?
In order not to get up twice, ask another question: in my example, as you can see, I use Eager Fetch to show these my nested collections in jsp. But I also tried to do Hibernate.initialize (containerObject OR List <containerobject>), but it does not work: LazyInitialization remains.
Why does not Hibernate.initialize work? I thought he was just for such cases. I also tried to use my hibernateTemplate.initialize () (through which, by the way, I run the Criteria), the result is the same.