|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.solarmetric.kodo.impl.jdbc.sql.SQLBuffer
Buffer for SQL statements. A SQLBuffer holds a list of SQLElement
objects, which will be concatinated to build a meaningful SQL
representation. The SQL that is held in a SQLBuffer is not
datastore-agnostic. The SQLElement implementations
that are added to the list are arbitrary, but typically
values that will not usefully be parameterized by the data store will
be added as SQLLiterals, and values that can be parameterized
will be added as SQLValues. This allows the runtime envionment
to be able to re-use existing PreparedStatement objects with
a high cache hit ratio, while still maintaining meaningful
parameterization of the SQL statements.
Raw SQL suitable for use in a Statement can always be
accessed via the getStatementSQL method.
Example usage:
SQLBuffer query = new SQLBuffer ();
query.appendLiteral ("SELECT * FROM MYTABLE ");
SQLBuffer whereClause = new SQLBuffer ();
whereClause.appendLiteral ("WHERE ID = ");
whereClause.appendValue (new SQLValue (new Integer (10), dict, type));
query.appendBuffer (whereClause);
String selectSQL = query.getStatementSQL ();
This class is not thread-safe.
SQLValue,
SQLLiteral,
SQLElement, Serialized Form| Field Summary | |
(package private) List |
sql
|
| Constructor Summary | |
SQLBuffer()
Constructor. |
|
SQLBuffer(SQLBuffer toCopy)
Constructor. |
|
SQLBuffer(String rawSQL)
Constructor. |
|
| Method Summary | |
SQLBuffer |
appendBuffer(SQLBuffer buffer)
Append all elements of the specified SQLBuffer (shallowly) to this one. |
SQLBuffer |
appendLiteral(SQLLiteral literal)
Append some raw, un-preparable SQL to the statement. |
SQLBuffer |
appendLiteral(String rawSQL)
Append some raw, un-preparable SQL to the statement. |
SQLBuffer |
appendValue(SQLValue element)
Append a SQLValue. |
Object |
clone()
Perform a shallow clone of this SQL Buffer. |
boolean |
equals(Object other)
|
String |
getPreparedStatementSQL()
Obtain the String key can can be used to look up an equivalent PreparedStatement in a Map of String:PreparedStatement. |
String |
getStatementSQL()
Obtain the raw SQL that can be used in a Statement. |
int |
hashCode()
|
Iterator |
iterator()
Obtain an interator the the list of SQL Statements. |
int |
setParameters(PreparedStatement ps)
Populate the parameters of an existing PreparedStatement with values from this SQLBuffer. |
int |
setParameters(PreparedStatement ps,
int startIndex)
Populate the parameters of an existing PreparedStatement with values from this SQLBuffer. |
int |
size()
Returns the number of SQLElements contained in this buffer. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
final List sql
| Constructor Detail |
public SQLBuffer()
public SQLBuffer(String rawSQL)
public SQLBuffer(SQLBuffer toCopy)
| Method Detail |
public Object clone()
clone in class Objectpublic SQLBuffer appendLiteral(String rawSQL)
public SQLBuffer appendLiteral(SQLLiteral literal)
public SQLBuffer appendValue(SQLValue element)
public SQLBuffer appendBuffer(SQLBuffer buffer)
public String getPreparedStatementSQL()
public String getStatementSQL()
public int setParameters(PreparedStatement ps)
throws SQLException
public int setParameters(PreparedStatement ps,
int startIndex)
throws SQLException
public int size()
public Iterator iterator()
public int hashCode()
hashCode in class Objectpublic boolean equals(Object other)
equals in class Object
|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||