Package org.apache.openjpa.jdbc.kernel
Class PreparedStatementManagerImpl
- java.lang.Object
-
- org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl
-
- All Implemented Interfaces:
PreparedStatementManager
- Direct Known Subclasses:
BatchingPreparedStatementManagerImpl
public class PreparedStatementManagerImpl extends java.lang.Object implements PreparedStatementManager
Basic prepared statement manager implementation.- Author:
- Abe White
-
-
Field Summary
Fields Modifier and Type Field Description protected java.sql.Connection_connprotected DBDictionary_dictprotected java.util.Collection<java.lang.Exception>_exceptionsprotected Log_logprotected JDBCStore_store
-
Constructor Summary
Constructors Constructor Description PreparedStatementManagerImpl(JDBCStore store, java.sql.Connection conn)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intexecuteUpdate(java.sql.PreparedStatement stmnt, java.lang.String sql, RowImpl row)This method is to provide override for non-JDBC or JDBC-like implementation of executing update.voidflush()This method must be called after the last row has been flushed, to flush any remaining statements.voidflush(RowImpl row)Flush the given row.protected voidflushAndUpdate(RowImpl row)Flush the given row immediately.protected voidflushInternal(RowImpl row)Flush the given row.protected java.lang.String[]getAutoAssignColNames(Column[] autoAssign, RowImpl row)protected Column[]getAutoAssignColumns(RowImpl row)java.util.Collection<java.lang.Exception>getExceptions()Return the exceptions encountered during all flushes.protected java.util.List<java.lang.Object>getGeneratedKeys(java.sql.PreparedStatement stmnt, java.lang.String[] autoAssignColNames)This method will only be called when the database supports getGeneratedKeys.protected java.util.List<java.lang.Object>getGeneratedKeys(java.sql.PreparedStatement stmnt, DBIdentifier[] autoAssignColNames)protected voidlogSQLWarnings(java.sql.PreparedStatement stmt)Provided the JDBC log category is logging warnings, this method will log any SQL warnings that result from the execution of a SQL statement.protected voidlogSQLWarnings(java.sql.Statement stmt)protected java.util.List<java.lang.Object>populateAutoAssignCols(java.sql.PreparedStatement stmnt, Column[] autoAssign, java.lang.String[] autoAssignColNames, RowImpl row)protected java.util.List<java.lang.Object>populateAutoAssignCols(java.sql.PreparedStatement stmnt, Column[] autoAssign, DBIdentifier[] autoAssignColNames, RowImpl row)This method will only be called when there is auto assign columns.protected java.sql.PreparedStatementprepareStatement(java.lang.String sql)This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.protected java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] autoAssignColNames)This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.protected voidsetObjectId(java.util.List vals, Column[] autoAssign, java.lang.String[] autoAssignColNames, RowImpl row)protected voidsetObjectId(java.util.List vals, Column[] autoAssign, DBIdentifier[] autoAssignColNames, RowImpl row)
-
-
-
Field Detail
-
_store
protected final JDBCStore _store
-
_conn
protected final java.sql.Connection _conn
-
_dict
protected final DBDictionary _dict
-
_log
protected transient Log _log
-
_exceptions
protected final java.util.Collection<java.lang.Exception> _exceptions
-
-
Constructor Detail
-
PreparedStatementManagerImpl
public PreparedStatementManagerImpl(JDBCStore store, java.sql.Connection conn)
Constructor. Supply connection.
-
-
Method Detail
-
getExceptions
public java.util.Collection<java.lang.Exception> getExceptions()
Description copied from interface:PreparedStatementManagerReturn the exceptions encountered during all flushes.- Specified by:
getExceptionsin interfacePreparedStatementManager
-
flush
public void flush(RowImpl row)
Description copied from interface:PreparedStatementManagerFlush the given row.- Specified by:
flushin interfacePreparedStatementManager
-
flushInternal
protected void flushInternal(RowImpl row) throws java.sql.SQLException
Flush the given row.- Throws:
java.sql.SQLException
-
flushAndUpdate
protected void flushAndUpdate(RowImpl row) throws java.sql.SQLException
Flush the given row immediately.- Throws:
java.sql.SQLException
-
populateAutoAssignCols
protected java.util.List<java.lang.Object> populateAutoAssignCols(java.sql.PreparedStatement stmnt, Column[] autoAssign, DBIdentifier[] autoAssignColNames, RowImpl row) throws java.sql.SQLExceptionThis method will only be called when there is auto assign columns. If database supports getGeneratedKeys, the keys will be obtained from the result set associated with the stmnt. If not, a separate sql to select the key will be issued from DBDictionary.- Throws:
java.sql.SQLException
-
populateAutoAssignCols
protected java.util.List<java.lang.Object> populateAutoAssignCols(java.sql.PreparedStatement stmnt, Column[] autoAssign, java.lang.String[] autoAssignColNames, RowImpl row) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setObjectId
protected void setObjectId(java.util.List vals, Column[] autoAssign, java.lang.String[] autoAssignColNames, RowImpl row) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setObjectId
protected void setObjectId(java.util.List vals, Column[] autoAssign, DBIdentifier[] autoAssignColNames, RowImpl row) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getGeneratedKeys
protected java.util.List<java.lang.Object> getGeneratedKeys(java.sql.PreparedStatement stmnt, java.lang.String[] autoAssignColNames) throws java.sql.SQLExceptionThis method will only be called when the database supports getGeneratedKeys.- Throws:
java.sql.SQLException
-
getGeneratedKeys
protected java.util.List<java.lang.Object> getGeneratedKeys(java.sql.PreparedStatement stmnt, DBIdentifier[] autoAssignColNames) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getAutoAssignColNames
protected java.lang.String[] getAutoAssignColNames(Column[] autoAssign, RowImpl row)
-
flush
public void flush()
Description copied from interface:PreparedStatementManagerThis method must be called after the last row has been flushed, to flush any remaining statements.- Specified by:
flushin interfacePreparedStatementManager
-
executeUpdate
protected int executeUpdate(java.sql.PreparedStatement stmnt, java.lang.String sql, RowImpl row) throws java.sql.SQLExceptionThis method is to provide override for non-JDBC or JDBC-like implementation of executing update.- Throws:
java.sql.SQLException
-
prepareStatement
protected java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLExceptionThis method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.- Throws:
java.sql.SQLException
-
prepareStatement
protected java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] autoAssignColNames) throws java.sql.SQLExceptionThis method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.- Throws:
java.sql.SQLException
-
logSQLWarnings
protected void logSQLWarnings(java.sql.PreparedStatement stmt)
Provided the JDBC log category is logging warnings, this method will log any SQL warnings that result from the execution of a SQL statement.
-
logSQLWarnings
protected void logSQLWarnings(java.sql.Statement stmt)
-
-