LazyInitializationException when calling em.refresh() on entity with lazy and eager children

Description

The problem can be reproduced as follows:

  • given: entity with two collections, one lazy, the other eager

  • fetch an entity

  • refresh the entity

  • access the lazy collection → LazyInitializationException as the collection doesn’t contain a session (see below)

Reproducer:

Chat with the hibernate team: https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user/topic/H5-.3EH6.3A.20LazyInitializationException.20after.20em.2Erefresh.28.29

Issue from the Keycloak team:

 

Activity

Show:

Alexander Schwartz April 3, 2023 at 12:17 PM

In the Keycloak project, we’ll changed the code that we don’t need the refresh any more, and that this issue is not blocking us.
Still, it might haunt us in other places, therefore we’d like to see a fix eventually. Thanks!

Fixed

Details

Assignee

Reporter

Worked in

Components

Fix versions

Affects versions

Priority

Created April 3, 2023 at 12:13 PM
Updated May 18, 2023 at 1:05 PM
Resolved May 9, 2023 at 3:50 PM