public abstract class AbstractTransactionalQuery extends Object implements Serializable
Modifier and Type | Method and Description |
---|---|
void |
beginTransaction()
Reserves a connection with auto-commit off if no transaction is in
progress.
|
void |
commit()
Commits (if not in auto-commit mode) and releases the active connection.
|
protected void |
ensureTransaction()
Check that a transaction is active.
|
protected Connection |
getConnection()
Returns the currently active connection, reserves and returns a new
connection if no active connection.
|
protected boolean |
isInTransaction() |
protected void |
releaseConnection(Connection conn,
Statement statement,
ResultSet rs)
Closes a statement and a resultset, then releases the connection if it is
not part of an active transaction.
|
void |
rollback()
Rolls back and releases the active connection.
|
public void beginTransaction() throws UnsupportedOperationException, SQLException
IllegalStateException
- if a transaction is already openSQLException
- if a connection could not be obtained or configuredUnsupportedOperationException
public void commit() throws UnsupportedOperationException, SQLException
SQLException
- if not in a transaction managed by this queryUnsupportedOperationException
public void rollback() throws UnsupportedOperationException, SQLException
SQLException
- if not in a transaction managed by this queryUnsupportedOperationException
protected void ensureTransaction() throws SQLException
SQLException
- if no active transactionprotected void releaseConnection(Connection conn, Statement statement, ResultSet rs) throws SQLException
PreparedStatement
, its parameters are
cleared prior to closing the statement.
Although JDBC specification does state that closing a statement closes
its result set and closing a connection closes statements and result
sets, this method does try to close the result set and statement
explicitly whenever not null. This can guard against bugs in certain JDBC
drivers and reduce leaks in case e.g. closing the result set succeeds but
closing the statement or connection fails.conn
- the connection to releasestatement
- the statement to close, may be null to skip closingrs
- the result set to close, may be null to skip closingSQLException
- if closing the result set or the statement failsprotected Connection getConnection() throws SQLException
SQLException
protected boolean isInTransaction()
Copyright © 2021 Vaadin Ltd. All rights reserved.