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
_conn
protected DBDictionary
_dict
protected java.util.Collection<java.lang.Exception>
_exceptions
protected Log
_log
protected 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 int
executeUpdate(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.void
flush()
This method must be called after the last row has been flushed, to flush any remaining statements.void
flush(RowImpl row)
Flush the given row.protected void
flushAndUpdate(RowImpl row)
Flush the given row immediately.protected void
flushInternal(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 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.protected void
logSQLWarnings(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.PreparedStatement
prepareStatement(java.lang.String sql)
This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.protected java.sql.PreparedStatement
prepareStatement(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 void
setObjectId(java.util.List vals, Column[] autoAssign, java.lang.String[] autoAssignColNames, RowImpl row)
protected void
setObjectId(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:PreparedStatementManager
Return the exceptions encountered during all flushes.- Specified by:
getExceptions
in interfacePreparedStatementManager
-
flush
public void flush(RowImpl row)
Description copied from interface:PreparedStatementManager
Flush the given row.- Specified by:
flush
in 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.SQLException
This 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.SQLException
This 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:PreparedStatementManager
This method must be called after the last row has been flushed, to flush any remaining statements.- Specified by:
flush
in interfacePreparedStatementManager
-
executeUpdate
protected int executeUpdate(java.sql.PreparedStatement stmnt, java.lang.String sql, RowImpl row) throws java.sql.SQLException
This 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.SQLException
This 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.SQLException
This 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)
-
-