From b6ee342713ac11f1ff330e6bab3b4b11de43eb7e Mon Sep 17 00:00:00 2001 From: Wim Vandenhaute Date: Tue, 23 Apr 2019 13:07:17 +0200 Subject: [PATCH] KEYCLOAK-4593 Flush and clear when fetching multiple realms for performance improvement with large number of realms --- .../main/java/org/keycloak/models/jpa/JpaRealmProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 8c5f15c5c9..cd22a46fa9 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java @@ -117,7 +117,8 @@ public class JpaRealmProvider implements RealmProvider { for (String id : entities) { RealmModel realm = session.realms().getRealm(id); if (realm != null) realms.add(realm); - + em.flush(); + em.clear(); } return realms; } @@ -730,4 +731,4 @@ public class JpaRealmProvider implements RealmProvider { model.setTimestamp(entity.getTimestamp()); return model; } -} +} \ No newline at end of file