uk.co.kimble.cobra
Class SQLStatement

java.lang.Object
  |
  +--uk.co.kimble.cobra.SQLStatement
Direct Known Subclasses:
SQLDeleteStatement, SQLInsertStatement, SQLSelectStatement, SQLUpdateStatement

public abstract class SQLStatement
extends java.lang.Object

All statements are versions of SQLStatement.


Field Summary
protected  uk.co.kimble.cobra.ClassDictionary class_dictionary
           
protected  java.lang.String sql
           
 
Constructor Summary
SQLStatement(uk.co.kimble.cobra.ClassDictionary cd)
          Constructor
 
Method Summary
protected  java.lang.String asSQLClause(SelectionCriteria c)
           
protected  java.lang.String asSQLStatement(PersistentCriteria criteria)
           
 java.lang.String buildForCriteria(PersistentCriteria criteria)
          Build an SQL statement for the object restricted by some criteria
abstract  java.lang.String buildForObject()
          Every subclass must implement buildForObject, this method builds an SQL statment for the object as a string.
 uk.co.kimble.cobra.ClassDictionary getClassDictionary()
          Return the class dictionary used by this SQL statement
 void setKeyValues(java.sql.PreparedStatement ps, PersistentObject po)
          Set the primary key values in a prepared statement from the values in the corresponding persistent object attributed.
 void setValues(java.sql.PreparedStatement ps, PersistentCriteria criteria)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

class_dictionary

protected uk.co.kimble.cobra.ClassDictionary class_dictionary

sql

protected java.lang.String sql
Constructor Detail

SQLStatement

public SQLStatement(uk.co.kimble.cobra.ClassDictionary cd)
             throws PersistentException
Constructor
Parameters:
cd - ClassDictionary instance
Method Detail

buildForObject

public abstract java.lang.String buildForObject()
                                         throws PersistentException
Every subclass must implement buildForObject, this method builds an SQL statment for the object as a string. An SQL statement is mapped to a PersistentObject.
Throws:
PersistentException - if the class dictionary cannot be found

getClassDictionary

public uk.co.kimble.cobra.ClassDictionary getClassDictionary()
Return the class dictionary used by this SQL statement

buildForCriteria

public java.lang.String buildForCriteria(PersistentCriteria criteria)
Build an SQL statement for the object restricted by some criteria
Parameters:
Criteria - to restrict SQL statement

asSQLStatement

protected java.lang.String asSQLStatement(PersistentCriteria criteria)
Parameters:
criteria - Selection criteria 26/06/99 Change statement to a StringBuffer for efficiency

asSQLClause

protected java.lang.String asSQLClause(SelectionCriteria c)

setKeyValues

public void setKeyValues(java.sql.PreparedStatement ps,
                         PersistentObject po)
                  throws PersistentException
Set the primary key values in a prepared statement from the values in the corresponding persistent object attributed.
Parameters:
ps - Prepared statement
po - Persistent object corresponding to the prepared statement
Throws:
PersistentException - if the key values in po can't be accessed or their are no key values to set.

setValues

public void setValues(java.sql.PreparedStatement ps,
                      PersistentCriteria criteria)
               throws PersistentException