|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.healthmarketscience.common.util.AppendeeObject
com.healthmarketscience.sqlbuilder.SqlObject
com.healthmarketscience.sqlbuilder.QueryPreparer.PlaceHolder
public static class QueryPreparer.PlaceHolder
A SqlObject which outputs a '?', and records the current index at the
time the appendTo
method is called. This enables the user
to set parameters correctly in a PreparedStatement where the position is
not known at query creation time.
Note: a PlaceHolder may not be used in more than one place in
the query. For this functionality, use QueryPreparer.MultiPlaceHolder
.
Field Summary |
---|
Fields inherited from class com.healthmarketscience.sqlbuilder.SqlObject |
---|
ALL_SYMBOL, NULL_VALUE, QUESTION_MARK |
Constructor Summary | |
---|---|
QueryPreparer.PlaceHolder(QueryPreparer outer)
|
Method Summary | |
---|---|
protected void |
addIndex(int index)
|
void |
appendTo(AppendableExt app)
|
protected void |
collectSchemaObjects(ValidationContext vContext)
Used during Query.validate() calls to collect the dbschema objects referenced in a query. |
int |
getIndex()
Returns the 1-based index of this PlaceHolder in the query. |
List<Integer> |
getIndexes()
|
boolean |
isInQuery()
Returns true if this PlaceHolder was used in the query,
false otherwise. |
void |
setBoolean(boolean value,
PreparedStatement ps)
Calls setBoolean on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setBoolean(Boolean value,
PreparedStatement ps)
Calls setBoolean on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setInt(Integer value,
PreparedStatement ps)
Calls setInt on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setInt(int value,
PreparedStatement ps)
Calls setInt on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setLong(long value,
PreparedStatement ps)
Calls setLong on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setLong(Long value,
PreparedStatement ps)
Calls setLong on the given PreparedStatement with the given value for the position of this PlaceHolder. |
protected void |
setNonNullObject(Object value,
int sqlType,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value and the given sql type for the position of this PlaceHolder. |
protected void |
setNonNullString(String value,
PreparedStatement ps)
Calls setString on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setNull(int sqlType,
PreparedStatement ps)
Calls setNull on the given PreparedStatement with the given sql type for the position of this PlaceHolder. |
void |
setObject(Object value,
int sqlType,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value and the given sql type for the position of this PlaceHolder. |
void |
setObject(Object value,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value for the position of this PlaceHolder. |
void |
setString(String value,
PreparedStatement ps)
Calls setString on the given PreparedStatement with the given value for the position of this PlaceHolder. |
Methods inherited from class com.healthmarketscience.sqlbuilder.SqlObject |
---|
doValidate, toString |
Methods inherited from class com.healthmarketscience.common.util.AppendeeObject |
---|
toString, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public QueryPreparer.PlaceHolder(QueryPreparer outer)
Method Detail |
---|
public boolean isInQuery()
true
if this PlaceHolder was used in the query,
false
otherwise.
public int getIndex()
public List<Integer> getIndexes()
protected void addIndex(int index)
public void setNull(int sqlType, PreparedStatement ps) throws SQLException
SQLException
public void setInt(int value, PreparedStatement ps) throws SQLException
SQLException
public void setInt(Integer value, PreparedStatement ps) throws SQLException
null
,
calls setNull with the sql type INTEGER
.
SQLException
public void setLong(long value, PreparedStatement ps) throws SQLException
SQLException
public void setLong(Long value, PreparedStatement ps) throws SQLException
null
,
calls setNull with the sql type BIGINT
.
SQLException
public void setBoolean(boolean value, PreparedStatement ps) throws SQLException
SQLException
public void setBoolean(Boolean value, PreparedStatement ps) throws SQLException
null
,
calls setNull with the sql type BOOLEAN
.
SQLException
protected void setNonNullString(String value, PreparedStatement ps) throws SQLException
SQLException
public void setString(String value, PreparedStatement ps) throws SQLException
SQLException
public void setObject(Object value, PreparedStatement ps) throws SQLException
null
value may or may not
work, depending on the JDBC driver. The only reliable (across all JDBC
drivers) way to set a null
object is to call
setObject(Object,int,PreparedStatement)
with the correct SQL
type.
SQLException
protected void setNonNullObject(Object value, int sqlType, PreparedStatement ps) throws SQLException
SQLException
public void setObject(Object value, int sqlType, PreparedStatement ps) throws SQLException
SQLException
protected void collectSchemaObjects(ValidationContext vContext)
SqlObject
collectSchemaObjects
in class SqlObject
vContext
- handle to the current validation contextpublic final void appendTo(AppendableExt app) throws IOException
appendTo
in interface Appendee
appendTo
in class AppendeeObject
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |