org.apache.ojb.broker.accesslayer.sql
Class SqlGeneratorDefaultImpl

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
All Implemented Interfaces:
SqlGenerator

public class SqlGeneratorDefaultImpl
extends Object
implements SqlGenerator

This Class is responsible for building sql statements Objects fields and their repective values are accessed by Java reflection

Version:
$Id: SqlGeneratorDefaultImpl.java,v 1.1 2007-08-24 22:17:39 ewestfal Exp $
Author:
Thomas Mahler, Ron Gallagher, Randall Burt

Nested Class Summary
static class SqlGeneratorDefaultImpl.SqlForClass
          This class serves as a cache for sql-Statements used for persistence operations.
 
Field Summary
private  Logger logger
           
private  Platform m_platform
           
private  Map sqlForClass
          Cache for SqlGeneratorDefaultImpl.SqlForClass instances, keyed per class descriptor.
 
Constructor Summary
SqlGeneratorDefaultImpl(Platform platform)
           
 
Method Summary
protected  String asSQLClause(SelectionCriteria c, ClassDescriptor cld)
          Answer the SQL-Clause for a SelectionCriteria
 String asSQLStatement(Criteria crit, ClassDescriptor cld)
           
 String getDeleteMNStatement(String table, String[] pkColumns1, String[] pkColumns2)
          generate a DELETE-Statement for M:N indirection table
 String getInsertMNStatement(String table, String[] pkColumns1, String[] pkColumns2)
          generate an INSERT-Statement for M:N indirection table
 Platform getPlatform()
          Answer the Platform used by the SqlGenerator
 SqlStatement getPreparedDeleteStatement(ClassDescriptor cld)
          generate a prepared DELETE-Statement for the Class described by cld.
 SqlStatement getPreparedDeleteStatement(Query query, ClassDescriptor cld)
          generate a prepared DELETE-Statement according to query
 SqlStatement getPreparedExistsStatement(ClassDescriptor cld)
           
 SqlStatement getPreparedInsertStatement(ClassDescriptor cld)
          generate a prepared INSERT-Statement for the Class described by cld.
 SelectStatement getPreparedSelectByPkStatement(ClassDescriptor cld)
          generate a prepared SELECT-Statement for the Class described by cld
 SelectStatement getPreparedSelectStatement(Query query, ClassDescriptor cld)
          generate a select-Statement according to query
 SqlStatement getPreparedUpdateStatement(ClassDescriptor cld)
          generate a prepared UPDATE-Statement for the Class described by cld
 String getSelectMNStatement(String table, String[] selectColumns, String[] columns)
          generate a SELECT-Statement for M:N indirection table
 SelectStatement getSelectStatementDep(Query query, ClassDescriptor cld)
          generate a select-Statement according to query
protected  SqlGeneratorDefaultImpl.SqlForClass getSqlForClass(ClassDescriptor cld)
          Returns the SqlGeneratorDefaultImpl.SqlForClass instance for the given class descriptor.
protected  SqlGeneratorDefaultImpl.SqlForClass newInstanceSqlForClass()
          User who want to extend this implementation can override this method to use their own (extended) version of SqlGeneratorDefaultImpl.SqlForClass.
private  String toSQLClause(BetweenCriteria c, ClassDescriptor cld)
          Answer the SQL-Clause for a BetweenCriteria
private  String toSQLClause(ExistsCriteria c, ClassDescriptor cld)
          Answer the SQL-Clause for an ExistsCriteria
private  String toSQLClause(FieldCriteria c, ClassDescriptor cld)
          Answer the SQL-Clause for a FieldCriteria
private  String toSQLClause(InCriteria c)
          Answer the SQL-Clause for an InCriteria
private  String toSQLClause(NullCriteria c)
          Answer the SQL-Clause for a NullCriteria
private  String toSqlClause(Object attributeOrQuery, ClassDescriptor cld)
           
private  String toSQLClause(SelectionCriteria c, ClassDescriptor cld)
          Answer the SQL-Clause for a SelectionCriteria
private  String toSQLClause(SqlCriteria c)
          Answer the SQL-Clause for a SqlCriteria
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private Logger logger

m_platform

private Platform m_platform

sqlForClass

private Map sqlForClass
Cache for SqlGeneratorDefaultImpl.SqlForClass instances, keyed per class descriptor.

Constructor Detail

SqlGeneratorDefaultImpl

public SqlGeneratorDefaultImpl(Platform platform)
Method Detail

getPreparedDeleteStatement

public SqlStatement getPreparedDeleteStatement(ClassDescriptor cld)
generate a prepared DELETE-Statement for the Class described by cld.

Specified by:
getPreparedDeleteStatement in interface SqlGenerator
Parameters:
cld - the ClassDescriptor

getPreparedInsertStatement

public SqlStatement getPreparedInsertStatement(ClassDescriptor cld)
generate a prepared INSERT-Statement for the Class described by cld.

Specified by:
getPreparedInsertStatement in interface SqlGenerator
Parameters:
cld - the ClassDescriptor

getPreparedSelectByPkStatement

public SelectStatement getPreparedSelectByPkStatement(ClassDescriptor cld)
generate a prepared SELECT-Statement for the Class described by cld

Specified by:
getPreparedSelectByPkStatement in interface SqlGenerator
Parameters:
cld - the ClassDescriptor

getPreparedExistsStatement

public SqlStatement getPreparedExistsStatement(ClassDescriptor cld)

getPreparedSelectStatement

public SelectStatement getPreparedSelectStatement(Query query,
                                                  ClassDescriptor cld)
generate a select-Statement according to query

Specified by:
getPreparedSelectStatement in interface SqlGenerator
Parameters:
query - the Query
cld - the ClassDescriptor

getPreparedUpdateStatement

public SqlStatement getPreparedUpdateStatement(ClassDescriptor cld)
generate a prepared UPDATE-Statement for the Class described by cld

Specified by:
getPreparedUpdateStatement in interface SqlGenerator
Parameters:
cld - the ClassDescriptor

getInsertMNStatement

public String getInsertMNStatement(String table,
                                   String[] pkColumns1,
                                   String[] pkColumns2)
generate an INSERT-Statement for M:N indirection table

Specified by:
getInsertMNStatement in interface SqlGenerator
Parameters:
table -
pkColumns1 -
pkColumns2 -
Returns:
String

getSelectMNStatement

public String getSelectMNStatement(String table,
                                   String[] selectColumns,
                                   String[] columns)
generate a SELECT-Statement for M:N indirection table

Specified by:
getSelectMNStatement in interface SqlGenerator
Parameters:
table - the indirection table
selectColumns - selected columns
columns - for where

getDeleteMNStatement

public String getDeleteMNStatement(String table,
                                   String[] pkColumns1,
                                   String[] pkColumns2)
generate a DELETE-Statement for M:N indirection table

Specified by:
getDeleteMNStatement in interface SqlGenerator
Parameters:
table -
pkColumns1 -
pkColumns2 -
Returns:
String

getSelectStatementDep

public SelectStatement getSelectStatementDep(Query query,
                                             ClassDescriptor cld)
generate a select-Statement according to query

Specified by:
getSelectStatementDep in interface SqlGenerator
Parameters:
query - the Query
cld - the ClassDescriptor

asSQLStatement

public String asSQLStatement(Criteria crit,
                             ClassDescriptor cld)
Parameters:
crit - Selection criteria 26/06/99 Change statement to a StringBuffer for efficiency

asSQLClause

protected String asSQLClause(SelectionCriteria c,
                             ClassDescriptor cld)
Answer the SQL-Clause for a SelectionCriteria

Parameters:
c - SelectionCriteria
cld - ClassDescriptor

toSqlClause

private String toSqlClause(Object attributeOrQuery,
                           ClassDescriptor cld)

toSQLClause

private String toSQLClause(NullCriteria c)
Answer the SQL-Clause for a NullCriteria

Parameters:
c - NullCriteria

toSQLClause

private String toSQLClause(FieldCriteria c,
                           ClassDescriptor cld)
Answer the SQL-Clause for a FieldCriteria

Parameters:
c - FieldCriteria
cld - ClassDescriptor

toSQLClause

private String toSQLClause(BetweenCriteria c,
                           ClassDescriptor cld)
Answer the SQL-Clause for a BetweenCriteria

Parameters:
c - BetweenCriteria
cld - ClassDescriptor

toSQLClause

private String toSQLClause(InCriteria c)
Answer the SQL-Clause for an InCriteria

Parameters:
c - SelectionCriteria

toSQLClause

private String toSQLClause(SelectionCriteria c,
                           ClassDescriptor cld)
Answer the SQL-Clause for a SelectionCriteria

Parameters:
c - SelectionCriteria
cld - ClassDescriptor

toSQLClause

private String toSQLClause(SqlCriteria c)
Answer the SQL-Clause for a SqlCriteria

Parameters:
c - SqlCriteria

toSQLClause

private String toSQLClause(ExistsCriteria c,
                           ClassDescriptor cld)
Answer the SQL-Clause for an ExistsCriteria

Parameters:
c - ExistsCriteria
cld - ClassDescriptor

getPreparedDeleteStatement

public SqlStatement getPreparedDeleteStatement(Query query,
                                               ClassDescriptor cld)
generate a prepared DELETE-Statement according to query

Specified by:
getPreparedDeleteStatement in interface SqlGenerator
Parameters:
query - the Query
cld - the ClassDescriptor

getPlatform

public Platform getPlatform()
Description copied from interface: SqlGenerator
Answer the Platform used by the SqlGenerator

Specified by:
getPlatform in interface SqlGenerator
Returns:
Platform

getSqlForClass

protected SqlGeneratorDefaultImpl.SqlForClass getSqlForClass(ClassDescriptor cld)
Returns the SqlGeneratorDefaultImpl.SqlForClass instance for the given class descriptor.

Parameters:
cld - The class descriptor.
Returns:
The SqlGeneratorDefaultImpl.SqlForClass.

newInstanceSqlForClass

protected SqlGeneratorDefaultImpl.SqlForClass newInstanceSqlForClass()
User who want to extend this implementation can override this method to use their own (extended) version of SqlGeneratorDefaultImpl.SqlForClass.

Returns:
A new instance.


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.