|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.castor.cpa.persistence.sql.query.QueryContext
public class QueryContext
Function of QueryContext is 3 fold. It offers information about small syntax differences of database engines. For example about quoting of qualifier and column names. In addition it is a builder for SQL query strings. Third function is to map parameter names to indices and offer a method to bind values to these named parameters.
| Constructor Summary | |
|---|---|
QueryContext()
Default constructor for a delete query that does not quote qualifier and column names. |
|
QueryContext(PersistenceFactory factory)
Constructor that uses given factory instance to quote qualifier and column names. |
|
| Method Summary | |
|---|---|
void |
addParameter(String name)
Add a named parameter to the query context. |
QueryContext |
append(char chr)
Append the given character to end of SQL query string. |
QueryContext |
append(String str)
Append the given string to end of SQL query string. |
void |
bindParameter(PreparedStatement stmt,
String name,
Object value,
int type)
Bind value of named parameter to prepared statement. |
String |
getSequenceNextValString(String seqName)
Returns the database engine specific string to fetch sequence next value. |
int |
parameterSize()
Returns the number of parameter in sql insert statement. |
String |
quoteName(String name)
Returns the quoted identifier suitable for preventing conflicts between database identifiers and reserved keywords. |
String |
toString()
Returns the SQL query string build by previous calls to one of the append methods. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public QueryContext()
public QueryContext(PersistenceFactory factory)
factory - Persistence factory for the database engine the entity is persisted in.
Used to format the SQL statement.| Method Detail |
|---|
public String quoteName(String name)
name - The identifier (table, column, etc).
public String getSequenceNextValString(String seqName)
seqName - Name of the sequence.
public final QueryContext append(char chr)
chr - Character to append.
public final QueryContext append(String str)
str - String to append.
public final String toString()
toString in class Objectpublic final void addParameter(String name)
name - Name of the parameter.
public final void bindParameter(PreparedStatement stmt,
String name,
Object value,
int type)
throws SQLException
stmt - Prepared statement to bind value of named parameter to.name - Name of the parameter to bind.value - Value of the named parameter to bind.type - SQL column type.
SQLException - If a database access error occurs or the type of the given object
is ambiguous.public final int parameterSize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||