org.apache.ojb.broker.accesslayer
Class StatementsForClassImpl

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.StatementsForClassImpl
All Implemented Interfaces:
StatementsForClassIF

public class StatementsForClassImpl
extends Object
implements StatementsForClassIF

This class serves as a cache for Statements that are used for persistence operations on a given class.

Version:
$Id: StatementsForClassImpl.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
Author:
Thomas Mahler

Field Summary
protected  ClassDescriptor classDescriptor
          sets the escape processing mode
protected  Class clazz
           
protected  int fetchSize
           
protected  boolean FORCEJDBC1_0
          force use of JDBC 1.0 statement creation
protected  Platform platform
           
protected  SqlGenerator sqlGenerator
           
 
Constructor Summary
StatementsForClassImpl(JdbcConnectionDescriptor jcd, ClassDescriptor classDescriptor)
           
 
Method Summary
 PreparedStatement getDeleteStmt(Connection con)
          Returns the DELETE Statement used for clazz.
 Statement getGenericStmt(Connection con, boolean scrollable)
          Returns a generic unprepared Statement used for clazz.
 PreparedStatement getInsertStmt(Connection con)
          Returns the INSERT Statement used for clazz.
 PreparedStatement getPreparedStmt(Connection con, String sql, boolean scrollable, int explicitFetchSizeHint, boolean callableStmt)
          Returns a prepared Statement used for clazz.
 PreparedStatement getSelectByPKStmt(Connection con)
          Returns the SELECT Statement used for clazz.
 PreparedStatement getUpdateStmt(Connection con)
          Returns the UPDATE Statement used for clazz.
protected  PreparedStatement prepareStatement(Connection con, String sql, boolean scrollable, boolean createPreparedStatement, int explicitFetchSizeHint)
          Prepares a statement with parameters that should work with most RDBMS.
protected  boolean usePreparedDeleteStatement()
          Answer true if a PreparedStatement has to be used
false for a CallableStatement
protected  boolean usePreparedInsertStatement()
          Answer true if a PreparedStatement has to be used
false for a CallableStatement
protected  boolean usePreparedUpdateStatement()
          Answer true if a PreparedStatement has to be used
false for a CallableStatement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classDescriptor

protected final ClassDescriptor classDescriptor
sets the escape processing mode


sqlGenerator

protected final SqlGenerator sqlGenerator

platform

protected final Platform platform

clazz

protected final Class clazz

fetchSize

protected final int fetchSize

FORCEJDBC1_0

protected boolean FORCEJDBC1_0
force use of JDBC 1.0 statement creation

Constructor Detail

StatementsForClassImpl

public StatementsForClassImpl(JdbcConnectionDescriptor jcd,
                              ClassDescriptor classDescriptor)
Method Detail

usePreparedDeleteStatement

protected boolean usePreparedDeleteStatement()
Answer true if a PreparedStatement has to be used
false for a CallableStatement


getDeleteStmt

public PreparedStatement getDeleteStmt(Connection con)
                                throws SQLException
Description copied from interface: StatementsForClassIF
Returns the DELETE Statement used for clazz.

Specified by:
getDeleteStmt in interface StatementsForClassIF
Returns:
java.sql.PreparedStatement
Throws:
SQLException

getGenericStmt

public Statement getGenericStmt(Connection con,
                                boolean scrollable)
                         throws PersistenceBrokerSQLException
Description copied from interface: StatementsForClassIF
Returns a generic unprepared Statement used for clazz. Never use this method for UPDATE/INSERT/DELETE if you want to use the batch mode.

Specified by:
getGenericStmt in interface StatementsForClassIF
Returns:
java.sql.Statement
Throws:
PersistenceBrokerSQLException

usePreparedInsertStatement

protected boolean usePreparedInsertStatement()
Answer true if a PreparedStatement has to be used
false for a CallableStatement


getInsertStmt

public PreparedStatement getInsertStmt(Connection con)
                                throws SQLException
Description copied from interface: StatementsForClassIF
Returns the INSERT Statement used for clazz.

Specified by:
getInsertStmt in interface StatementsForClassIF
Returns:
java.sql.PreparedStatement
Throws:
SQLException

getPreparedStmt

public PreparedStatement getPreparedStmt(Connection con,
                                         String sql,
                                         boolean scrollable,
                                         int explicitFetchSizeHint,
                                         boolean callableStmt)
                                  throws PersistenceBrokerSQLException
Description copied from interface: StatementsForClassIF
Returns a prepared Statement used for clazz.

Specified by:
getPreparedStmt in interface StatementsForClassIF
Returns:
java.sql.Statement
Throws:
PersistenceBrokerSQLException

getSelectByPKStmt

public PreparedStatement getSelectByPKStmt(Connection con)
                                    throws SQLException
Description copied from interface: StatementsForClassIF
Returns the SELECT Statement used for clazz.

Specified by:
getSelectByPKStmt in interface StatementsForClassIF
Returns:
java.sql.PreparedStatement
Throws:
SQLException

usePreparedUpdateStatement

protected boolean usePreparedUpdateStatement()
Answer true if a PreparedStatement has to be used
false for a CallableStatement


getUpdateStmt

public PreparedStatement getUpdateStmt(Connection con)
                                throws SQLException
Description copied from interface: StatementsForClassIF
Returns the UPDATE Statement used for clazz.

Specified by:
getUpdateStmt in interface StatementsForClassIF
Returns:
java.sql.PreparedStatement
Throws:
SQLException

prepareStatement

protected PreparedStatement prepareStatement(Connection con,
                                             String sql,
                                             boolean scrollable,
                                             boolean createPreparedStatement,
                                             int explicitFetchSizeHint)
                                      throws SQLException
Prepares a statement with parameters that should work with most RDBMS.

Parameters:
con - the connection to utilize
sql - the sql syntax to use when creating the statement.
scrollable - determines if the statement will be scrollable.
createPreparedStatement - if true, then a PreparedStatement will be created. If false, then a CallableStatement will be created.
explicitFetchSizeHint - will be used as fetchSize hint (if applicable) if > 0
Returns:
a statement that can be used to execute the syntax contained in the sql argument.
Throws:
SQLException


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.