How to initialize collection collections in Hibernate

I get util.Listinstances. each copy has its own different collection. I want to initialize all collection instances. Here's how to do it.

Hibernate.initialize(parentList);  

But when the session is closed. Properties of parent objects can be restored. But its properties of collection instances cannot be restored. Is the way I initialize incorrect or is there any other problem? or how to initialize all instances.?

+3
source share
2 answers
Hibernate.initialize(parentList);

will just initialize the objects in the list that are not connected inside the list.

From the docs:

. - ; , INSIDE /.

:

, Student Entity, Entity Course Entity. :

for (Student student : studentList) {
     Hibernate.initialize(student.getCourses());
}
+10

- Value .

0

All Articles