From 28975b950d53dc3f3b3a59022642e3784937f8fc Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Thu, 16 Mar 2023 13:25:46 +0100 Subject: [PATCH] Workaround for lazy loaded collections for RealmEntity --- Quarkus3 branch sync no. 13 (11.4.2023) Resolved conflicts: keycloak/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java - Modified --- .../main/java/org/keycloak/models/jpa/JpaRealmProvider.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java index c9d379fd7f..9987e149d3 100644 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java @@ -166,6 +166,12 @@ public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientSc if (realm == null) { return false; } + + // Workaround tracked by issue https://github.com/keycloak/keycloak/pull/19069 + // As of Hibernate 6.2.0.CR3, after the em.refresh(entity) the lazily loaded collections in realm don't load anymore, instead there is a + // LazyInitializationException. As a workaround, comment out the refresh call. + // em.refresh(realm); + final RealmAdapter adapter = new RealmAdapter(session, em, realm); session.users().preRemove(adapter);