Package fr.paris.lutece.util.sql
Class MultiPluginTransaction
- java.lang.Object
-
- fr.paris.lutece.util.sql.Transaction
-
- fr.paris.lutece.util.sql.MultiPluginTransaction
-
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.
-
-
Field Summary
-
Fields inherited from class fr.paris.lutece.util.sql.Transaction
COMMITTED, OPENED, ROLLEDBACK
-
-
Constructor Summary
Constructors Constructor Description MultiPluginTransaction()ConstructorMultiPluginTransaction(Plugin plugin)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Commit the transactionvoiddecrementNbTransactionsOpened()Decrement the number of transactions by one.voidexecuteStatement()Execute the current statementintgetNbTransactionsOpened()Get the number of transactions that plugins tried to open simultaneously on the same pool.voidincrementNbTransactionsOpened()Increment the number of transactions by one.java.sql.PreparedStatementprepareStatement(java.lang.String strSQL)Gets a prepared statementjava.sql.PreparedStatementprepareStatement(java.lang.String strSQL, boolean bLogQueries)Gets a prepared statementjava.sql.PreparedStatementprepareStatement(java.lang.String strSQL, java.lang.Integer autoGeneratedKeys)Gets a prepared statementjava.sql.PreparedStatementprepareStatement(java.lang.String strSQL, java.lang.Integer autoGeneratedKeys, boolean bLogQueries)Gets a prepared statementvoidrollback(java.lang.Exception e)Rollback the transaction-
Methods inherited from class fr.paris.lutece.util.sql.Transaction
getStatement, getStatus, rollback
-
-
-
-
Constructor Detail
-
MultiPluginTransaction
public MultiPluginTransaction()
Constructor
-
MultiPluginTransaction
public MultiPluginTransaction(Plugin plugin)
Constructor- Parameters:
plugin- The plugin owner of the transaction
-
-
Method Detail
-
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
public java.sql.PreparedStatement prepareStatement(java.lang.String strSQL, boolean bLogQueries) throws java.sql.SQLExceptionGets a prepared statement- Overrides:
prepareStatementin classTransaction- Parameters:
strSQL- The SQL statement- Returns:
- The prepared statement
- Throws:
java.sql.SQLException- If an SQL error occurs
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String strSQL) throws java.sql.SQLExceptionGets a prepared statement- Overrides:
prepareStatementin classTransaction- Parameters:
strSQL- The SQL statement- Returns:
- The prepared statement
- Throws:
java.sql.SQLException- If an SQL error occurs
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String strSQL, java.lang.Integer autoGeneratedKeys) throws java.sql.SQLExceptionGets a prepared statement- Overrides:
prepareStatementin classTransaction- Parameters:
strSQL- The SQL statement- Returns:
- The prepared statement
- Throws:
java.sql.SQLException- If an SQL error occurs
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String strSQL, java.lang.Integer autoGeneratedKeys, boolean bLogQueries) throws java.sql.SQLExceptionGets 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:
java.sql.SQLException- If an SQL error occurs
-
executeStatement
public void executeStatement() throws java.sql.SQLExceptionExecute the current statement- Overrides:
executeStatementin classTransaction- Throws:
java.sql.SQLException- If an SQL error occurs
-
commit
public void commit()
Commit the transaction- Overrides:
commitin classTransaction
-
rollback
public void rollback(java.lang.Exception e)
Rollback the transaction- Overrides:
rollbackin classTransaction- Parameters:
e- The exception that cause the rollback
-
-