Class SpiTransactionProxy

java.lang.Object
io.ebeaninternal.api.SpiTransactionProxy
All Implemented Interfaces:
Transaction, SpiTransaction, AutoCloseable
Direct Known Subclasses:
ScopedTransaction

public abstract class SpiTransactionProxy extends Object implements SpiTransaction
Proxy for an underlying SpiTransaction (most of the API).
  • Field Details

  • Constructor Details

    • SpiTransactionProxy

      public SpiTransactionProxy()
  • Method Details

    • translate

      public jakarta.persistence.PersistenceException translate(String message, SQLException cause)
      Description copied from interface: SpiTransaction
      Translate the SQLException.
      Specified by:
      translate in interface SpiTransaction
    • startNanoTime

      public long startNanoTime()
      Description copied from interface: SpiTransaction
      Return the start timestamp for the transaction (JVM side).
      Specified by:
      startNanoTime in interface SpiTransaction
    • setLabel

      public void setLabel(String label)
      Specified by:
      setLabel in interface Transaction
    • label

      public String label()
      Description copied from interface: SpiTransaction
      Return the user defined label for the transaction.
      Specified by:
      label in interface SpiTransaction
    • setAutoPersistUpdates

      public void setAutoPersistUpdates(boolean autoPersistUpdates)
      Specified by:
      setAutoPersistUpdates in interface Transaction
    • isAutoPersistUpdates

      public boolean isAutoPersistUpdates()
      Description copied from interface: SpiTransaction
      Return true if dirty beans are automatically persisted.
      Specified by:
      isAutoPersistUpdates in interface SpiTransaction
    • commitAndContinue

      public void commitAndContinue()
      Specified by:
      commitAndContinue in interface Transaction
    • isRollbackOnly

      public boolean isRollbackOnly()
      Specified by:
      isRollbackOnly in interface Transaction
    • setNestedUseSavepoint

      public void setNestedUseSavepoint()
      Specified by:
      setNestedUseSavepoint in interface Transaction
    • isNestedUseSavepoint

      public boolean isNestedUseSavepoint()
      Description copied from interface: SpiTransaction
      Return true when nested transactions should create Savepoints.
      Specified by:
      isNestedUseSavepoint in interface SpiTransaction
    • profileOffset

      public long profileOffset()
      Description copied from interface: SpiTransaction
      Return the offset time from the start of the transaction.
      Specified by:
      profileOffset in interface SpiTransaction
    • profileEvent

      public void profileEvent(SpiProfileTransactionEvent event)
      Description copied from interface: SpiTransaction
      Check if the event should be added to a profiling transaction.
      Specified by:
      profileEvent in interface SpiTransaction
    • setProfileStream

      public void setProfileStream(ProfileStream profileStream)
      Description copied from interface: SpiTransaction
      Set the profileStream to catch and time all the events for this transaction.
      Specified by:
      setProfileStream in interface SpiTransaction
    • profileStream

      public ProfileStream profileStream()
      Description copied from interface: SpiTransaction
      Return the stream that profiling events are written to.
      Specified by:
      profileStream in interface SpiTransaction
    • setProfileLocation

      public void setProfileLocation(ProfileLocation profileLocation)
      Description copied from interface: SpiTransaction
      Set the profile location for this transaction.
      Specified by:
      setProfileLocation in interface SpiTransaction
    • profileLocation

      public ProfileLocation profileLocation()
      Description copied from interface: SpiTransaction
      Return the profile location for this transaction.
      Specified by:
      profileLocation in interface SpiTransaction
    • setTenantId

      public void setTenantId(Object tenantId)
      Description copied from interface: SpiTransaction
      Set the current Tenant Id.
      Specified by:
      setTenantId in interface SpiTransaction
    • tenantId

      public Object tenantId()
      Description copied from interface: SpiTransaction
      Return the current Tenant Id.
      Specified by:
      tenantId in interface SpiTransaction
    • isLogSql

      public boolean isLogSql()
      Description copied from interface: SpiTransaction
      Return true if generated SQL and Bind values should be logged to the transaction log.
      Specified by:
      isLogSql in interface SpiTransaction
    • isLogSummary

      public boolean isLogSummary()
      Description copied from interface: SpiTransaction
      Return true if summary level events should be logged to the transaction log.
      Specified by:
      isLogSummary in interface SpiTransaction
    • logSql

      public void logSql(String msg, Object... args)
      Description copied from interface: SpiTransaction
      Log a message to the SQL logger.
      Specified by:
      logSql in interface SpiTransaction
    • logSummary

      public void logSummary(String msg, Object... args)
      Description copied from interface: SpiTransaction
      Log a summary message to the SUMMARY logger.
      Specified by:
      logSummary in interface SpiTransaction
    • logTxn

      public void logTxn(String msg, Object... args)
      Description copied from interface: SpiTransaction
      Log a transaction message to the transaction logger.
      Specified by:
      logTxn in interface SpiTransaction
    • setSkipCache

      public void setSkipCache(boolean skipCache)
      Specified by:
      setSkipCache in interface Transaction
    • isSkipCacheExplicit

      public boolean isSkipCacheExplicit()
      Description copied from interface: SpiTransaction
      Return true if explicitly set to skip cache (ignores skipOnWrite).
      Specified by:
      isSkipCacheExplicit in interface SpiTransaction
    • isSkipCache

      public boolean isSkipCache()
      Specified by:
      isSkipCache in interface Transaction
    • addBeanChange

      public void addBeanChange(BeanChange beanChange)
      Description copied from interface: SpiTransaction
      Add a bean change to the change log.
      Specified by:
      addBeanChange in interface SpiTransaction
    • sendChangeLog

      public void sendChangeLog(ChangeSet changes)
      Description copied from interface: SpiTransaction
      Send the change set to be prepared and then logged.
      Specified by:
      sendChangeLog in interface SpiTransaction
    • registerDeferred

      public void registerDeferred(PersistDeferredRelationship derived)
      Description copied from interface: SpiTransaction
      Register a "Deferred Relationship" that requires an additional update later.
      Specified by:
      registerDeferred in interface SpiTransaction
    • registerDeleteBean

      public void registerDeleteBean(Integer hash)
      Description copied from interface: SpiTransaction
      Add a deleting bean to the registered list.

      This is to handle bi-directional relationships where both sides Cascade.

      Specified by:
      registerDeleteBean in interface SpiTransaction
    • isRegisteredDeleteBean

      public boolean isRegisteredDeleteBean(Integer hash)
      Description copied from interface: SpiTransaction
      Return true if this is a bean that has already been saved/deleted.
      Specified by:
      isRegisteredDeleteBean in interface SpiTransaction
    • unregisterBeans

      public void unregisterBeans()
      Description copied from interface: SpiTransaction
      Unregister the persisted beans. Expected after persisting top level beans and hence including all beans that were cascade persisted.
      Specified by:
      unregisterBeans in interface SpiTransaction
    • isRegisteredBean

      public boolean isRegisteredBean(Object bean)
      Description copied from interface: SpiTransaction
      Return true if this is a bean that has already been persisted in the current recursive save request. The goal is to stop recursively saving the bean when cascade persist is on both sides of a relationship).

      This will register the bean if it is not already.

      Specified by:
      isRegisteredBean in interface SpiTransaction
    • id

      public String id()
      Description copied from interface: SpiTransaction
      Returns a String used to identify the transaction. This id is used for Transaction logging.
      Specified by:
      id in interface SpiTransaction
    • register

      public void register(TransactionCallback callback)
      Specified by:
      register in interface Transaction
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface Transaction
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Specified by:
      setReadOnly in interface Transaction
    • isActive

      public boolean isActive()
      Specified by:
      isActive in interface Transaction
    • setPersistCascade

      public void setPersistCascade(boolean persistCascade)
      Specified by:
      setPersistCascade in interface Transaction
    • setUpdateAllLoadedProperties

      public void setUpdateAllLoadedProperties(boolean updateAllLoaded)
      Specified by:
      setUpdateAllLoadedProperties in interface Transaction
    • isUpdateAllLoadedProperties

      public Boolean isUpdateAllLoadedProperties()
      Description copied from interface: SpiTransaction
      Return true if this transaction has updateAllLoadedProperties set. If null is returned the server default is used (set on DatabaseConfig).
      Specified by:
      isUpdateAllLoadedProperties in interface SpiTransaction
    • setBatchMode

      public void setBatchMode(boolean useBatch)
      Specified by:
      setBatchMode in interface Transaction
    • isBatchMode

      public boolean isBatchMode()
      Specified by:
      isBatchMode in interface Transaction
    • setBatchOnCascade

      public void setBatchOnCascade(boolean batchMode)
      Specified by:
      setBatchOnCascade in interface Transaction
    • isBatchOnCascade

      public boolean isBatchOnCascade()
      Specified by:
      isBatchOnCascade in interface Transaction
    • setBatchSize

      public void setBatchSize(int batchSize)
      Specified by:
      setBatchSize in interface Transaction
    • getBatchSize

      public int getBatchSize()
      Description copied from interface: SpiTransaction
      Return the batchSize specifically set for this transaction or 0.

      Returning 0 implies to use the system wide default batch size.

      Specified by:
      getBatchSize in interface SpiTransaction
      Specified by:
      getBatchSize in interface Transaction
    • setGetGeneratedKeys

      public void setGetGeneratedKeys(boolean getGeneratedKeys)
      Specified by:
      setGetGeneratedKeys in interface Transaction
    • getBatchGetGeneratedKeys

      public Boolean getBatchGetGeneratedKeys()
      Description copied from interface: SpiTransaction
      Return the getGeneratedKeys setting for this transaction.
      Specified by:
      getBatchGetGeneratedKeys in interface SpiTransaction
    • setFlushOnMixed

      public void setFlushOnMixed(boolean batchFlushOnMixed)
      Specified by:
      setFlushOnMixed in interface Transaction
    • setFlushOnQuery

      public void setFlushOnQuery(boolean batchFlushOnQuery)
      Specified by:
      setFlushOnQuery in interface Transaction
    • isFlushOnQuery

      public boolean isFlushOnQuery()
      Specified by:
      isFlushOnQuery in interface Transaction
    • flush

      public void flush() throws jakarta.persistence.PersistenceException
      Specified by:
      flush in interface Transaction
      Throws:
      jakarta.persistence.PersistenceException
    • connection

      public Connection connection()
      Specified by:
      connection in interface Transaction
    • addModification

      public void addModification(String tableName, boolean inserts, boolean updates, boolean deletes)
      Specified by:
      addModification in interface Transaction
    • putUserObject

      public void putUserObject(String name, Object value)
      Specified by:
      putUserObject in interface Transaction
    • getUserObject

      public Object getUserObject(String name)
      Specified by:
      getUserObject in interface Transaction
    • depth

      public void depth(int diff)
      Description copied from interface: SpiTransaction
      Modify the current 'depth' of the transaction.

      As we cascade save or delete we traverse the object graph tree. Going up to Assoc Ones the depth decreases and going down to Assoc Manys the depth increases.

      The depth is used for ordering batching statements. The lowest depth get executed first during save.

      Specified by:
      depth in interface SpiTransaction
    • depthDecrement

      public void depthDecrement()
      Description copied from interface: SpiTransaction
      Decrement the depth BUT only if depth is greater than 0. Return the amount that depth should be incremented by (0 or 1).
      Specified by:
      depthDecrement in interface SpiTransaction
    • depthReset

      public void depthReset()
      Description copied from interface: SpiTransaction
      Reset the depth back to 0 - done at the end of top level insert and update.
      Specified by:
      depthReset in interface SpiTransaction
    • depth

      public int depth()
      Description copied from interface: SpiTransaction
      Return the current depth.
      Specified by:
      depth in interface SpiTransaction
    • isExplicit

      public boolean isExplicit()
      Description copied from interface: SpiTransaction
      Return true if this transaction was created explicitly via Ebean.beginTransaction().
      Specified by:
      isExplicit in interface SpiTransaction
    • event

      public TransactionEvent event()
      Description copied from interface: SpiTransaction
      Get the object that holds the event details.

      This information is used maintain the table state, cache and text indexes. On commit the Table modifications this generates is broadcast around the cluster (if you have a cluster).

      Specified by:
      event in interface SpiTransaction
    • isPersistCascade

      public boolean isPersistCascade()
      Description copied from interface: SpiTransaction
      Whether persistCascade is on for save and delete.
      Specified by:
      isPersistCascade in interface SpiTransaction
    • isBatchThisRequest

      public boolean isBatchThisRequest()
      Description copied from interface: SpiTransaction
      Return true if this request should be batched. Conversely returns false if this request should be executed immediately.
      Specified by:
      isBatchThisRequest in interface SpiTransaction
    • batchControl

      public BatchControl batchControl()
      Description copied from interface: SpiTransaction
      Return the BatchControl used to batch up persist requests.
      Specified by:
      batchControl in interface SpiTransaction
    • setBatchControl

      public void setBatchControl(BatchControl control)
      Description copied from interface: SpiTransaction
      Set the BatchControl used to batch up persist requests. There should only be one PersistQueue set per transaction.
      Specified by:
      setBatchControl in interface SpiTransaction
    • persistenceContext

      public SpiPersistenceContext persistenceContext()
      Description copied from interface: SpiTransaction
      Return the persistence context associated with this transaction.

      You may wish to hold onto this and set it against another transaction later. This is along the lines of 'extended persistence context' behaviour.

      Specified by:
      persistenceContext in interface SpiTransaction
    • setPersistenceContext

      public void setPersistenceContext(SpiPersistenceContext context)
      Description copied from interface: SpiTransaction
      Set the persistence context to this transaction.

      This could be considered similar to 'EJB3 Extended Persistence Context'. In that you can get the PersistenceContext from a transaction, hold onto it, and then set it back later to a second transaction. In general there is one PersistenceContext per Transaction. The getPersistenceContext() and setPersistenceContext() enable a developer to reuse a single PersistenceContext with multiple transactions.

      Specified by:
      setPersistenceContext in interface SpiTransaction
    • internalConnection

      public Connection internalConnection()
      Description copied from interface: SpiTransaction
      Return the underlying Connection for internal use.

      If the connection is made from Transaction and the user code calls that method we can no longer trust the query only status of a Transaction.

      Specified by:
      internalConnection in interface SpiTransaction
    • isSaveAssocManyIntersection

      public boolean isSaveAssocManyIntersection(String intersectionTable, String beanName)
      Description copied from interface: SpiTransaction
      Return true if the manyToMany intersection should be persisted for this particular relationship direction.
      Specified by:
      isSaveAssocManyIntersection in interface SpiTransaction
    • checkBatchEscalationOnCascade

      public boolean checkBatchEscalationOnCascade(PersistRequestBean<?> request)
      Description copied from interface: SpiTransaction
      Return true if batch mode got escalated for this request (and associated cascades).
      Specified by:
      checkBatchEscalationOnCascade in interface SpiTransaction
    • flushBatchOnCascade

      public void flushBatchOnCascade()
      Description copied from interface: SpiTransaction
      If batch mode was turned on for the request then flush the batch.
      Specified by:
      flushBatchOnCascade in interface SpiTransaction
    • flushBatchOnRollback

      public void flushBatchOnRollback()
      Description copied from interface: SpiTransaction
      If batch was on then effectively clear the batch such that we can handle exceptions and continue.
      Specified by:
      flushBatchOnRollback in interface SpiTransaction
    • markNotQueryOnly

      public void markNotQueryOnly()
      Description copied from interface: SpiTransaction
      Mark the transaction explicitly as not being query only.
      Specified by:
      markNotQueryOnly in interface SpiTransaction
    • checkBatchEscalationOnCollection

      public void checkBatchEscalationOnCollection()
      Description copied from interface: SpiTransaction
      Potentially escalate batch mode on saving or deleting a collection.
      Specified by:
      checkBatchEscalationOnCollection in interface SpiTransaction
    • flushBatchOnCollection

      public void flushBatchOnCollection()
      Description copied from interface: SpiTransaction
      Flush batch if we escalated batch mode on saving or deleting a collection.
      Specified by:
      flushBatchOnCollection in interface SpiTransaction
    • preCommit

      public void preCommit()
      Description copied from interface: SpiTransaction
      Fire pre commit processing/listeners.
      Specified by:
      preCommit in interface SpiTransaction
    • postCommit

      public void postCommit()
      Description copied from interface: SpiTransaction
      Fire post commit events and listeners.
      Specified by:
      postCommit in interface SpiTransaction
    • postRollback

      public void postRollback(Throwable cause)
      Description copied from interface: SpiTransaction
      Fire post rollback events and listeners.
      Specified by:
      postRollback in interface SpiTransaction
    • deactivateExternal

      public void deactivateExternal()
      Description copied from interface: SpiTransaction
      Set the transaction to be inactive via external transaction manager.
      Specified by:
      deactivateExternal in interface SpiTransaction