Class LocalTransactionInterceptor

java.lang.Object
org.mybatis.cdi.LocalTransactionInterceptor
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JtaTransactionInterceptor

@Interceptor public class LocalTransactionInterceptor extends Object implements Serializable
Best-effort interceptor for local transactions. It locates all the instances of SqlSssionManager and starts transactions on all them. It cannot guarantee atomiticy if there is more than one SqlSssionManager. Use XA drivers, a JTA container and the JtaTransactionInterceptor in that case.
Author:
Frank David Martínez
See Also:
  • Constructor Details

    • LocalTransactionInterceptor

      public LocalTransactionInterceptor()
  • Method Details

    • invoke

      public Object invoke(jakarta.interceptor.InvocationContext ctx) throws Exception
      Invoke.
      Parameters:
      ctx - the ctx
      Returns:
      the object
      Throws:
      Exception - the exception
    • isTransactionActive

      protected boolean isTransactionActive() throws jakarta.transaction.SystemException
      Checks if is transaction active.
      Returns:
      true, if is transaction active
      Throws:
      jakarta.transaction.SystemException - used by jtaTransactionInterceptor
    • beginJta

      protected void beginJta() throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemException
      Begin jta.
      Throws:
      jakarta.transaction.NotSupportedException - used by jtaTransactionInterceptor
      jakarta.transaction.SystemException - used by jtaTransactionInterceptor
    • endJta

      protected void endJta(boolean isExternaTransaction, boolean commit) throws jakarta.transaction.SystemException, jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException
      End jta.
      Parameters:
      isExternaTransaction - the is externa transaction
      commit - the commit
      Throws:
      jakarta.transaction.SystemException - used by jtaTransactionInterceptor
      jakarta.transaction.RollbackException - used by jtaTransactionInterceptor
      jakarta.transaction.HeuristicMixedException - used by jtaTransactionInterceptor
      jakarta.transaction.HeuristicRollbackException - used by jtaTransactionInterceptor
    • getTransactionalAnnotation

      protected Transactional getTransactionalAnnotation(jakarta.interceptor.InvocationContext ctx)