java.lang.Object
io.hypersistence.optimizer.core.event.persistence.EventStore

public class EventStore extends Object
The EventStore persists events into the database using plain JDBC and batched INSERT statements.

The tables are keyed by a database IDENTITY column, so the writes work reliably across multiple application nodes without any application-generated identifiers. The JDBC Connection is borrowed from the host application's SessionFactory through the ConnectionExecutor, which runs each unit of work inside a Hibernate transaction using SharedSessionContract.doWork(org.hibernate.jdbc.Work). No entity is ever persisted through the Session, so the runtime scanner is not re-triggered and there is no risk of recursion.

Since:
2.14.0
Author:
Vlad Mihalcea
  • Constructor Details

  • Method Details

    • insertRun

      public long insertRun(String hibernateVersion, List<Event> bootstrapEvents) throws SQLException
      Insert a run (a bootstrap snapshot) and its associated configuration and mapping events, using a single batched statement for the events. The runtime rollups inserted afterward reference this run.
      Parameters:
      hibernateVersion - the current Hibernate version
      bootstrapEvents - the configuration and mapping events collected during scanning
      Returns:
      the generated run identifier
      Throws:
      SQLException - if a database access error occurs
    • insertRuntimeRollups

      public void insertRuntimeRollups(Collection<RuntimeRollup> rollups) throws SQLException
      Insert the aggregated runtime rollups using a batched statement. The rollups reference the run inserted by insertRun(java.lang.String, java.util.List<io.hypersistence.optimizer.core.event.Event>), or have a NULL run_id if there is none.
      Parameters:
      rollups - the rollups to persist
      Throws:
      SQLException - if a database access error occurs