Class TransactionManager

java.lang.Object
io.ebeaninternal.server.transaction.TransactionManager
All Implemented Interfaces:
SpiTransactionManager

public class TransactionManager extends Object implements SpiTransactionManager
Manages transactions.

Keeps the Cache and Cluster in sync when transactions are committed.

  • Constructor Details

  • Method Details

    • scope

      public final TransactionScopeManager scope()
      Return the scope manager.
      Specified by:
      scope in interface SpiTransactionManager
    • set

      public final void set(SpiTransaction txn)
      Set the transaction onto the scope.
    • active

      public final SpiTransaction active()
      Return the current active transaction.
      Specified by:
      active in interface SpiTransactionManager
    • inScope

      public final SpiTransaction inScope()
      Return the current transaction from thread local scope. Note that it may be inactive.
    • translate

      public final jakarta.persistence.PersistenceException translate(String message, SQLException cause)
      Translate the SQLException into a specific exception if possible based on the DB platform.
    • shutdown

      public final void shutdown(boolean shutdownDataSource, boolean deregisterDriver)
    • descriptorManager

      public final BeanDescriptorManager descriptorManager()
    • name

      public final String name()
    • queryPlanConnection

      public final Connection queryPlanConnection() throws SQLException
      Description copied from interface: SpiTransactionManager
      Return a connection used for query plan collection.
      Specified by:
      queryPlanConnection in interface SpiTransactionManager
      Throws:
      SQLException
    • dataSource

      public final DataSource dataSource()
      Description copied from interface: SpiTransactionManager
      Return the main DataSource.
      Specified by:
      dataSource in interface SpiTransactionManager
    • readOnlyDataSource

      public final @Nullable DataSource readOnlyDataSource()
      Description copied from interface: SpiTransactionManager
      Return the read only DataSource (if defined).
      Specified by:
      readOnlyDataSource in interface SpiTransactionManager
    • wrapExternalConnection

      public SpiTransaction wrapExternalConnection(Connection c)
      Wrap the externally supplied Connection.
    • createTransaction

      public SpiTransaction createTransaction(boolean explicit, int isolationLevel)
      Create a new Transaction.
    • createReadOnlyTransaction

      public SpiTransaction createReadOnlyTransaction(Object tenantId, boolean useMaster)
      Create a new Transaction for query only purposes (can use read only datasource).
    • notifyOfRollback

      public final void notifyOfRollback(SpiTransaction transaction, Throwable cause)
      Process a local rolled back transaction.
      Specified by:
      notifyOfRollback in interface SpiTransactionManager
    • notifyOfQueryOnly

      public final void notifyOfQueryOnly(SpiTransaction transaction)
      Query only transaction in read committed isolation.
      Specified by:
      notifyOfQueryOnly in interface SpiTransactionManager
    • notifyOfCommit

      public final void notifyOfCommit(SpiTransaction transaction)
      Process a local committed transaction.
      Specified by:
      notifyOfCommit in interface SpiTransactionManager
    • externalModification

      public final void externalModification(TransactionEventTable tableEvent)
    • remoteTransactionEvent

      public final void remoteTransactionEvent(RemoteTransactionEvent remoteEvent)
      Notify local BeanPersistListeners etc of events from another server in the cluster.
    • visitMetrics

      public final void visitMetrics(io.ebean.meta.MetricVisitor visitor)
    • clearServerTransaction

      public final void clearServerTransaction()
      Clear an implicit transaction from thread local scope.
    • beginServerTransaction

      public final SpiTransaction beginServerTransaction()
      Begin an implicit transaction.
    • exitScopedTransaction

      public final void exitScopedTransaction(Object returnOrThrowable, int opCode)
      Exit a scoped transaction (that can be inactive - already committed etc).
    • externalRemoveTransaction

      public final void externalRemoveTransaction()
      Description copied from interface: SpiTransactionManager
      Called when an externally managed transaction has completed.
      Specified by:
      externalRemoveTransaction in interface SpiTransactionManager
    • externalBeginTransaction

      public final ScopedTransaction externalBeginTransaction(SpiTransaction transaction, io.ebean.TxScope txScope)
      Push an externally created transaction into scope. This transaction is usually managed externally (e.g. Spring managed transaction).
      Specified by:
      externalBeginTransaction in interface SpiTransactionManager
    • beginScopedTransaction

      public final ScopedTransaction beginScopedTransaction(io.ebean.TxScope txScope)
      Begin a scoped transaction.
    • logger

      public SpiTxnLogger logger()
    • loggerReadOnly

      public SpiTxnLogger loggerReadOnly()
    • log

      public final SpiLogManager log()
    • flushTransparent

      public final void flushTransparent(SpiPersistenceContext persistenceContext, SpiTransaction transaction)
      Experimental - find dirty beans in the persistence context and persist them.