|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jadetower.sql.impl.VelocitySQLEvaluator
An SQLEvaluator that uses Jakarta Velocity templates for SQL statement creation.
| Field Summary | |
static java.lang.String |
BIND_PARAMETERS
|
static java.lang.String |
SQL_KEY
|
| Constructor Summary | |
VelocitySQLEvaluator(java.io.Reader reader)
creates a new SQLEvalutor. |
|
| Method Summary | |
void |
clearContext()
clears the Velocity Context and creates a new one. |
void |
close()
attempts to close all result sets and prepared statements |
java.sql.ResultSet |
executeQuery(java.sql.Connection dbCon)
executes the query using the velocity template and a JDBC PreparedStatement |
java.util.Collection |
executeQuery(java.sql.Connection dbCon,
java.lang.Class beanClazz,
java.util.Map map)
executes query and maps results to a collection of type "beanClazz". |
int |
executeUpdate(java.sql.Connection dbCon)
executes INSERT, UPDATE, or DELETE statements |
java.lang.String |
getSQL()
Returns the SQL statement by evaluating a Velocity template. |
protected void |
initVelocity()
initialized Velocity runtime |
boolean |
isSQLMutable()
returns SQL mutability state. |
void |
set(java.lang.String key,
java.lang.Object value)
sets a value in the Velocity context |
void |
setContext(java.util.Map map)
puts all values of the map into the context. |
protected void |
setReader(java.io.Reader reader)
sets the template reader. |
void |
setSQLMutable(boolean mutable)
sets the mutability for SQL statements. |
protected void |
setVelocityContext(org.apache.velocity.VelocityContext context)
sets the Velocity context |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String BIND_PARAMETERS
public static final java.lang.String SQL_KEY
| Constructor Detail |
public VelocitySQLEvaluator(java.io.Reader reader)
reader - a reader to the Velocity template for the query.| Method Detail |
public void set(java.lang.String key,
java.lang.Object value)
set in interface SQLEvaluatorkey - context keyvalue - context valuepublic void setContext(java.util.Map map)
set(String key, Object value) method.
- Specified by:
setContext in interface SQLEvaluator
- Parameters:
map - context map
public java.lang.String getSQL()
throws java.sql.SQLException
getSQL in interface SQLEvaluatorjava.sql.SQLException - thrown if error created during template parsing
public java.sql.ResultSet executeQuery(java.sql.Connection dbCon)
throws java.sql.SQLException
executeQuery in interface SQLEvaluatordbCon - the database connection
java.sql.SQLException - thrown if JDBC or Template parsing error occurs
public java.util.Collection executeQuery(java.sql.Connection dbCon,
java.lang.Class beanClazz,
java.util.Map map)
throws java.sql.SQLException
executeQuery in interface SQLEvaluatordbCon - the JDBC database connectionbeanClazz - a Java Bean classmap - an alternate Column to Bean property mapping
java.sql.SQLException - thrown if JDBC, query parsing, or bean mapping error
occursSQLEvaluator
public int executeUpdate(java.sql.Connection dbCon)
throws java.sql.SQLException
executeUpdate in interface SQLEvaluatordbCon - a JDBC connection
java.sql.SQLException - thrown if JDBC or sql parsing error occursprotected void setReader(java.io.Reader reader)
reader - a reader to the templateprotected void setVelocityContext(org.apache.velocity.VelocityContext context)
context - a VelocityContext object
protected void initVelocity()
throws java.lang.Exception
java.lang.Exception - thrown if error initializing Velocity occurspublic void setSQLMutable(boolean mutable)
setSQLMutable in interface SQLEvaluatormutable - if false, SQL statements will be cached and updates to the
context ignored.public boolean isSQLMutable()
isSQLMutable in interface SQLEvaluatorSQLEvaluator.setSQLMutable(boolean mutable)public void clearContext()
clearContext in interface SQLEvaluator
public void close()
throws java.sql.SQLException
close in interface SQLEvaluatorjava.sql.SQLException - thrown if error during close
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||