Class EntityManagers
java.lang.Object
org.keycloak.connections.jpa.support.EntityManagers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
flush
(KeycloakSession session, boolean clear) Flush and optionally clear all the currently in useEntityManager
sstatic void
runInBatch
(KeycloakSession session, Runnable runnable, boolean nestedEntityManagers) Run the operation in batch mode with a pre-flush.
-
Constructor Details
-
EntityManagers
public EntityManagers()
-
-
Method Details
-
flush
Flush and optionally clear all the currently in useEntityManager
s -
runInBatch
public static void runInBatch(KeycloakSession session, Runnable runnable, boolean nestedEntityManagers) Run the operation in batch mode with a pre-flush.It is desirable to use nestedEntityManagers=true to keep the existing context free of newly created entities.
flush and detach operations are NOT automatically inhibited in batch mode. For even greater performance, and statement level batching by Hibernate, you may use the
isBatchMode()
to conditionally not perform those operations - however keep in mind that especially when running with nestedEntityManagers=false, the current persistence context will accumulate anything that is not detached.WARNING: Any queries run while batching will be in COMMIT mode, so they cannot see non-flushed changes made within the batch. Most of Keycloak's JPA code however persists and flushes together.
- Parameters:
nestedEntityManagers
- - if true run with isolated EntityManagers WARNING: Any entities passed into the task that that will get persisted must not already be associated with an open EntityManager.
-