Search code examples
javahibernatelazy-loadingeager-loading

Force eager loading of otherwise lazy loaded properties


I've got a Hibernate object which's properties are all loaded lazy. Most of these properties are other Hibernate objects or PersistentSets.

Now I want to force Hibernate to eager load these properties for just one time.

Of course I could "touch" each of these properties with object.getSite().size() but maybe there's another way to achieve my goal.


Solution

  • The documentation puts it like this:

    You can force the usual eager fetching of properties using fetch all properties in HQL.

    References