biz.hammurapi.web.util
Class DynaSQLProcessor

java.lang.Object
  extended bybiz.hammurapi.sql.SQLProcessor
      extended bybiz.hammurapi.web.util.DynaSQLProcessor
All Implemented Interfaces:
biz.hammurapi.config.Context

public class DynaSQLProcessor
extends biz.hammurapi.sql.SQLProcessor
implements biz.hammurapi.config.Context


Constructor Summary
DynaSQLProcessor(java.sql.Connection connection, biz.hammurapi.config.Context nameMap)
           
DynaSQLProcessor(javax.sql.DataSource dataSource, biz.hammurapi.config.Context nameMap)
           
 
Method Summary
 int delete(java.lang.String tableName, biz.hammurapi.config.Context criteriaCtx)
          Deletes data.
static java.lang.Class generateResultSetInterface(java.lang.String interfaceName, java.util.Map columnMap, biz.hammurapi.codegen.InterfacePool interfacePool, biz.hammurapi.codegen.InjectingClassLoader injectingClassLoader)
           
 java.lang.Object get(java.lang.String sql)
          Executes SQL and returns single object.
 void insert(java.lang.String tableName, biz.hammurapi.config.Context ctx)
          Inserts data into table.
 void processDatabaseMetaData(DatabaseMetaDataProcessor processor)
          Processes database metadata.
 java.util.List project(java.sql.ResultSet rs)
          This method generates dynamic interface from result set metadata and projects result set to this collection
static java.lang.Object project(java.sql.ResultSet rs, java.lang.Class resultInterface, java.util.Map columnMap)
           
 java.util.Collection select(java.lang.String sql)
          Executes SQL query, projects results to dynamically generated interface implementation.
 java.util.Collection select(java.lang.String sql, biz.hammurapi.config.Context params)
          Executes SQL query, projects results to dynamically generated interface implementation.
 java.util.Collection select(java.lang.String sql, java.util.List params)
          Executes SQL query, projects results to dynamically generated interface implementation.
 java.lang.Object selectSingleObject(java.lang.String sql)
          Executes SQL query, projects first row to dynamically generated interface implementation.
 java.lang.Object selectSingleObject(java.lang.String sql, biz.hammurapi.config.Context params)
          Executes SQL query, projects first row to dynamically generated interface implementation.
 java.lang.Object selectSingleObject(java.lang.String sql, java.util.List params)
          Executes SQL query, projects first row to dynamically generated interface implementation.
 int update(java.lang.String sql, biz.hammurapi.config.Context params)
           
 int update(java.lang.String tableName, biz.hammurapi.config.Context ctx, biz.hammurapi.config.Context criteriaCtx)
          Updated table data.
 int update(java.lang.String sql, java.util.List parameters)
           
 
Methods inherited from class biz.hammurapi.sql.SQLProcessor
executeScript, executeScript, executeScript, executeTransaction, findProjectSingleMethodName, getConnection, getDataSource, getNameMap, getTimeIntervalCategory, inject, main, nextPK, nextPK, parse, processResourceSelect, processResourceUpdate, processSelect, processUpdate, project, project, project, project, project, project, project, project, project, project, project, project, projectSingleBoolean, projectSingleByte, projectSingleBytes, projectSingleChar, projectSingleDouble, projectSingleFloat, projectSingleInt, projectSingleLong, projectSingleObject, projectSingleObject, projectSingleObject, projectSingleObject, projectSingleShort, projectSingleString, releaseConnection, setTimeIntervalCategory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynaSQLProcessor

public DynaSQLProcessor(javax.sql.DataSource dataSource,
                        biz.hammurapi.config.Context nameMap)

DynaSQLProcessor

public DynaSQLProcessor(java.sql.Connection connection,
                        biz.hammurapi.config.Context nameMap)
Method Detail

select

public java.util.Collection select(java.lang.String sql)
                            throws java.sql.SQLException
Executes SQL query, projects results to dynamically generated interface implementation. Results are put to ArrayList. If result set has one column then string value of this column is put to resulting collection.

Parameters:
sql -
Returns:
ArrayList of dynamic proxies.
Throws:
java.sql.SQLException

select

public java.util.Collection select(java.lang.String sql,
                                   java.util.List params)
                            throws java.sql.SQLException
Executes SQL query, projects results to dynamically generated interface implementation. Results are put to ArrayList. If result set has one column then string value of this column is put to resulting collection.

Parameters:
sql -
params - Array of query parameters.
Returns:
ArrayList of dynamic proxies.
Throws:
java.sql.SQLException

select

public java.util.Collection select(java.lang.String sql,
                                   biz.hammurapi.config.Context params)
                            throws java.sql.SQLException
Executes SQL query, projects results to dynamically generated interface implementation. Results are put to ArrayList. If result set has one column then string value of this column is put to resulting collection.

Parameters:
sql -
params - Context to retrieve parameters from. In SQL parameters shall be present in a form ${param name}. This call preprocesses SQL and replaces ${...} with a question mark. At the same time it retrieves parameter value from the context
Returns:
ArrayList of dynamic proxies.
Throws:
java.sql.SQLException

selectSingleObject

public java.lang.Object selectSingleObject(java.lang.String sql)
                                    throws java.sql.SQLException
Executes SQL query, projects first row to dynamically generated interface implementation. If result set has one column then string value of this column is returned.

Parameters:
sql -
Returns:
Dynamic proxy representing the first row in result set or null.
Throws:
java.sql.SQLException

selectSingleObject

public java.lang.Object selectSingleObject(java.lang.String sql,
                                           java.util.List params)
                                    throws java.sql.SQLException
Executes SQL query, projects first row to dynamically generated interface implementation. If result set has one column then string value of this column is returned.

Parameters:
sql -
Returns:
Dynamic proxy representing the first row in result set or null.
Throws:
java.sql.SQLException

selectSingleObject

public java.lang.Object selectSingleObject(java.lang.String sql,
                                           biz.hammurapi.config.Context params)
                                    throws java.sql.SQLException
Executes SQL query, projects first row to dynamically generated interface implementation. If result set has one column then string value of this column is returned.

Parameters:
sql -
Returns:
Dynamic proxy representing the first row in result set or null.
Throws:
java.sql.SQLException

project

public java.util.List project(java.sql.ResultSet rs)
                       throws java.sql.SQLException
This method generates dynamic interface from result set metadata and projects result set to this collection

Returns:
Throws:
java.sql.SQLException

project

public static java.lang.Object project(java.sql.ResultSet rs,
                                       java.lang.Class resultInterface,
                                       java.util.Map columnMap)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

generateResultSetInterface

public static java.lang.Class generateResultSetInterface(java.lang.String interfaceName,
                                                         java.util.Map columnMap,
                                                         biz.hammurapi.codegen.InterfacePool interfacePool,
                                                         biz.hammurapi.codegen.InjectingClassLoader injectingClassLoader)
                                                  throws biz.hammurapi.codegen.GenerationException,
                                                         java.lang.ClassNotFoundException
Throws:
biz.hammurapi.codegen.GenerationException
java.lang.ClassNotFoundException

processDatabaseMetaData

public void processDatabaseMetaData(DatabaseMetaDataProcessor processor)
                             throws java.sql.SQLException
Processes database metadata.

Parameters:
processor -
Throws:
java.sql.SQLException

get

public java.lang.Object get(java.lang.String sql)
Executes SQL and returns single object. Typical usage for this method retrieving scalar values from the database.

Specified by:
get in interface biz.hammurapi.config.Context

insert

public void insert(java.lang.String tableName,
                   biz.hammurapi.config.Context ctx)
            throws java.sql.SQLException
Inserts data into table. Values are taken from context.

Parameters:
tableName -
ctx -
Throws:
java.sql.SQLException

update

public int update(java.lang.String tableName,
                  biz.hammurapi.config.Context ctx,
                  biz.hammurapi.config.Context criteriaCtx)
           throws java.sql.SQLException
Updated table data. WHERE clause is built from criteriaCtx

Parameters:
tableName -
ctx -
criteriaCtx -
Throws:
java.sql.SQLException

delete

public int delete(java.lang.String tableName,
                  biz.hammurapi.config.Context criteriaCtx)
           throws java.sql.SQLException
Deletes data. WHERE clause is built from criteriaCtx

Parameters:
tableName -
criteriaCtx -
Throws:
java.sql.SQLException

update

public int update(java.lang.String sql,
                  java.util.List parameters)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

update

public int update(java.lang.String sql,
                  biz.hammurapi.config.Context params)
           throws java.sql.SQLException
Throws:
java.sql.SQLException


Copyright © 2006 Hammurapi Group. All Rights Reserved.