KEYCLOAK-4593 Flush and clear when fetching multiple realms for performance improvement with large number of realms

This commit is contained in:
Wim Vandenhaute 2019-04-23 13:07:17 +02:00 committed by Hynek Mlnařík
parent a32c8c5190
commit b6ee342713

View file

@ -117,7 +117,8 @@ public class JpaRealmProvider implements RealmProvider {
for (String id : entities) { for (String id : entities) {
RealmModel realm = session.realms().getRealm(id); RealmModel realm = session.realms().getRealm(id);
if (realm != null) realms.add(realm); if (realm != null) realms.add(realm);
em.flush();
em.clear();
} }
return realms; return realms;
} }
@ -730,4 +731,4 @@ public class JpaRealmProvider implements RealmProvider {
model.setTimestamp(entity.getTimestamp()); model.setTimestamp(entity.getTimestamp());
return model; return model;
} }
} }