org.apache.ojb.broker.accesslayer
Class StatementsForClassImpl

java.lang.Object
  extended byorg.apache.ojb.broker.accesslayer.StatementsForClassImpl
All Implemented Interfaces:
StatementsForClassIF
Direct Known Subclasses:
SQLCachingStatementsForClass

public class StatementsForClassImpl
extends java.lang.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.19 2004/02/08 13:19:47 tomdz Exp $
Author:
Thomas Mahler

Field Summary
protected  ClassDescriptor classDescriptor
          sets the escape processing mode
protected  java.lang.Class clazz
           
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
 java.sql.PreparedStatement getDeleteStmt(java.sql.Connection con)
          returns the DELETE Statement used for clazz.
 java.sql.Statement getGenericStmt(java.sql.Connection con, boolean scrollable)
          returns a generic unprepared Statement used for clazz.
 java.sql.PreparedStatement getInsertStmt(java.sql.Connection con)
          returns the INSERT Statement used for clazz.
 java.sql.PreparedStatement getPreparedStmt(java.sql.Connection con, java.lang.String sql, boolean scrollable)
          returns a prepared Statement used for clazz.
 java.sql.PreparedStatement getSelectByPKStmt(java.sql.Connection con)
          returns the SELECT Statement used for clazz.
 java.sql.PreparedStatement getUpdateStmt(java.sql.Connection con)
          returns the UPDATE Statement used for clazz.
 boolean isCached(java.sql.Statement stmt)
          For single VM operation to not eat up Oracle resources, we need to close the statements unless they are cached.
protected  java.sql.PreparedStatement prepareStatement(java.sql.Connection con, java.lang.String sql, boolean scrollable)
          Deprecated. use prepareStatement(Connection,String,boolean,boolean) instead.
protected  java.sql.PreparedStatement prepareStatement(java.sql.Connection con, java.lang.String sql, boolean scrollable, boolean createPreparedStatement)
          prepares a statement with parameters that should work with most RDBMS
protected  boolean usePreparedStatement()
          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 SqlGenerator sqlGenerator

platform

protected Platform platform

clazz

protected java.lang.Class clazz

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

isCached

public boolean isCached(java.sql.Statement stmt)
Description copied from interface: StatementsForClassIF
For single VM operation to not eat up Oracle resources, we need to close the statements unless they are cached.

Specified by:
isCached in interface StatementsForClassIF
Returns:
if the statement is of type select, insert, update, or delete

usePreparedStatement

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

Returns:

getDeleteStmt

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

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

getGenericStmt

public java.sql.Statement getGenericStmt(java.sql.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

getInsertStmt

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

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

getPreparedStmt

public java.sql.PreparedStatement getPreparedStmt(java.sql.Connection con,
                                                  java.lang.String sql,
                                                  boolean scrollable)
                                           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 java.sql.PreparedStatement getSelectByPKStmt(java.sql.Connection con)
                                             throws java.sql.SQLException
Description copied from interface: StatementsForClassIF
returns the SELECT Statement used for clazz.

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

getUpdateStmt

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

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

prepareStatement

protected java.sql.PreparedStatement prepareStatement(java.sql.Connection con,
                                                      java.lang.String sql,
                                                      boolean scrollable)
                                               throws java.sql.SQLException
Deprecated. use prepareStatement(Connection,String,boolean,boolean) instead.

prepares a statement with parameters that should work with most RDBMS

Throws:
java.sql.SQLException

prepareStatement

protected java.sql.PreparedStatement prepareStatement(java.sql.Connection con,
                                                      java.lang.String sql,
                                                      boolean scrollable,
                                                      boolean createPreparedStatement)
                                               throws java.sql.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.
Returns:
a statement that can be used to execute the syntax contained in the sql argument.
Throws:
java.sql.SQLException


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14