Package fr.paris.lutece.util.sql
Class MultiPluginTransaction
java.lang.Object
fr.paris.lutece.util.sql.Transaction
fr.paris.lutece.util.sql.MultiPluginTransaction
- All Implemented Interfaces:
AutoCloseable
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.
-
Field Summary
Fields inherited from class fr.paris.lutece.util.sql.Transaction
COMMITTED, OPENED, ROLLEDBACK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commit the transactionvoidDecrement the number of transactions by one.voidExecute the current statementintGet the number of transactions that plugins tried to open simultaneously on the same pool.voidIncrement the number of transactions by one.prepareStatement(String strSQL) Gets a prepared statementprepareStatement(String strSQL, boolean bLogQueries) Gets a prepared statementprepareStatement(String strSQL, Integer autoGeneratedKeys) Gets a prepared statementprepareStatement(String strSQL, Integer autoGeneratedKeys, boolean bLogQueries) Gets a prepared statementvoidRollback the transactionMethods inherited from class fr.paris.lutece.util.sql.Transaction
close, getStatement, getStatus, rollback
-
Constructor Details
-
MultiPluginTransaction
public MultiPluginTransaction()Constructor -
MultiPluginTransaction
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. SeegetNbTransactionsOpened()for more details. -
decrementNbTransactionsOpened
public void decrementNbTransactionsOpened()Decrement the number of transactions by one. SeegetNbTransactionsOpened()for more details. -
prepareStatement
Gets a prepared statement- Overrides:
prepareStatementin classTransaction- Parameters:
strSQL- The SQL statement- Returns:
- The prepared statement
- Throws:
SQLException- If an SQL error occurs
-
prepareStatement
Gets a prepared statement- Overrides:
prepareStatementin classTransaction- 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:
prepareStatementin classTransaction- 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:
prepareStatementin classTransaction- Parameters:
strSQL- The SQL statementautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; For example one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS. SeePreparedStatement#prepareStatement(String, int)- Returns:
- The prepared statement
- Throws:
SQLException- If an SQL error occurs
-
executeStatement
Execute the current statement- Overrides:
executeStatementin classTransaction- Throws:
SQLException- If an SQL error occurs
-
commit
public void commit()Commit the transaction- Overrides:
commitin classTransaction
-
rollback
Rollback the transaction- Overrides:
rollbackin classTransaction- Parameters:
e- The exception that cause the rollback
-