Class MultiPluginTransaction

java.lang.Object
fr.paris.lutece.util.sql.Transaction
fr.paris.lutece.util.sql.MultiPluginTransaction
All Implemented Interfaces:
AutoCloseable

public class MultiPluginTransaction extends Transaction
Class to represents transactions that are shared between plugins. Such transactions will be shared by each plugin using the same pool than the one that created the transaction.
  • Constructor Details

    • MultiPluginTransaction

      public MultiPluginTransaction()
      Constructor
    • MultiPluginTransaction

      public MultiPluginTransaction(Plugin plugin)
      Constructor
      Parameters:
      plugin - The plugin owner of the transaction
  • Method Details

    • getNbTransactionsOpened

      public int getNbTransactionsOpened()
      Get the number of transactions that plugins tried to open simultaneously on the same pool. If the number if 1, then the transaction can be safely committed. If it is more than 1, then this number should be decremented and the transaction should not be committed.
      Returns:
      The number of transactions that was required
    • incrementNbTransactionsOpened

      public void incrementNbTransactionsOpened()
      Increment the number of transactions by one. See getNbTransactionsOpened() for more details.
    • decrementNbTransactionsOpened

      public void decrementNbTransactionsOpened()
      Decrement the number of transactions by one. See getNbTransactionsOpened() for more details.
    • prepareStatement

      public PreparedStatement prepareStatement(String strSQL, boolean bLogQueries) throws SQLException
      Gets a prepared statement
      Overrides:
      prepareStatement in class Transaction
      Parameters:
      strSQL - The SQL statement
      Returns:
      The prepared statement
      Throws:
      SQLException - If an SQL error occurs
    • prepareStatement

      public PreparedStatement prepareStatement(String strSQL) throws SQLException
      Gets a prepared statement
      Overrides:
      prepareStatement in class Transaction
      Parameters:
      strSQL - The SQL statement
      Returns:
      The prepared statement
      Throws:
      SQLException - If an SQL error occurs
    • prepareStatement

      public PreparedStatement prepareStatement(String strSQL, Integer autoGeneratedKeys) throws SQLException
      Gets a prepared statement
      Overrides:
      prepareStatement in class Transaction
      Parameters:
      strSQL - The SQL statement
      Returns:
      The prepared statement
      Throws:
      SQLException - If an SQL error occurs
    • prepareStatement

      public PreparedStatement prepareStatement(String strSQL, Integer autoGeneratedKeys, boolean bLogQueries) throws SQLException
      Gets a prepared statement
      Overrides:
      prepareStatement in class Transaction
      Parameters:
      strSQL - The SQL statement
      autoGeneratedKeys - a flag indicating whether auto-generated keys should be returned; For example one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS. See PreparedStatement#prepareStatement(String, int)
      Returns:
      The prepared statement
      Throws:
      SQLException - If an SQL error occurs
    • executeStatement

      public void executeStatement() throws SQLException
      Execute the current statement
      Overrides:
      executeStatement in class Transaction
      Throws:
      SQLException - If an SQL error occurs
    • commit

      public void commit()
      Commit the transaction
      Overrides:
      commit in class Transaction
    • rollback

      public void rollback(Exception e)
      Rollback the transaction
      Overrides:
      rollback in class Transaction
      Parameters:
      e - The exception that cause the rollback