|
||||||||
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(java.lang.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(java.lang.String str)
Append the given string to end of SQL query string. |
void |
bindParameter(java.sql.PreparedStatement stmt,
java.lang.String name,
java.lang.Object value,
int type)
Bind value of named parameter to prepared statement. |
java.lang.String |
getSequenceNextValString(java.lang.String seqName)
Returns the database engine specific string to fetch sequence next value. |
int |
parameterSize()
Returns the number of parameter in sql insert statement. |
java.lang.String |
quoteName(java.lang.String name)
Returns the quoted identifier suitable for preventing conflicts between database identifiers and reserved keywords. |
java.lang.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 java.lang.String quoteName(java.lang.String name)
name
- The identifier (table, column, etc).
public java.lang.String getSequenceNextValString(java.lang.String seqName)
seqName
- Name of the sequence.
public final QueryContext append(char chr)
chr
- Character to append.
public final QueryContext append(java.lang.String str)
str
- String to append.
public final java.lang.String toString()
toString
in class java.lang.Object
public final void addParameter(java.lang.String name)
name
- Name of the parameter.public final void bindParameter(java.sql.PreparedStatement stmt, java.lang.String name, java.lang.Object value, int type) throws java.sql.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.
java.sql.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 |