public class SessionFactoryConnectionExecutor extends Object implements io.hypersistence.optimizer.util.ConnectionExecutor
SessionFactoryConnectionExecutor runs the event persistence JDBC work against a
Connection borrowed from the host application's Hibernate SessionFactory.
Because the Optimizer is always built on top of a SessionFactory (either a native one or
one unwrapped from a JPA EntityManagerFactory), reusing it means the events are stored
with the very same database credentials and connection pool as the application, and no separate
DataSource or JDBC URL needs to be configured.
The work is executed through Session.doWork(Work), which hands over a raw JDBC
Connection. No entity is ever persisted through the Session. However, the runtime
scanner that decorates the application SessionFactory still tracks the borrowed connection,
so the work runs within the InternalWorkScope, which drops the events it triggers. Otherwise,
every flush would report a StatementlessConnectionEvent about the Optimizer itself, and
persisting that event would trigger a new one, over and over.
| Constructor and Description |
|---|
SessionFactoryConnectionExecutor(org.hibernate.SessionFactory sessionFactory)
Instantiate the
SessionFactoryConnectionExecutor using the provided SessionFactory. |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(io.hypersistence.optimizer.util.ConnectionCallback callback) |
public SessionFactoryConnectionExecutor(org.hibernate.SessionFactory sessionFactory)
SessionFactoryConnectionExecutor using the provided SessionFactory.sessionFactory - the host application's SessionFactorypublic void execute(io.hypersistence.optimizer.util.ConnectionCallback callback)
throws SQLException
execute in interface io.hypersistence.optimizer.util.ConnectionExecutorSQLExceptionCopyright © 2026. All rights reserved.