public static class QueryPreparer.MultiPlaceHolder extends QueryPreparer.PlaceHolder
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 MultiPlaceHolder may be used in more than one place in the query.ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
Constructor and Description |
---|
MultiPlaceHolder(QueryPreparer outer) |
Modifier and Type | Method and Description |
---|---|
protected void |
addIndex(int index) |
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 |
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.
|
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,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
appendTo, collectSchemaObjects, getOuter, setBoolean, setInt, setLong, setObject, setString
collectSchemaObjects, doValidate, toString
toString, toString
public MultiPlaceHolder(QueryPreparer outer)
public List<Integer> getIndexes()
getIndexes
in class QueryPreparer.PlaceHolder
public boolean isInQuery()
QueryPreparer.PlaceHolder
true
if this PlaceHolder was used in the query,
false
otherwise.isInQuery
in class QueryPreparer.PlaceHolder
protected void addIndex(int index)
addIndex
in class QueryPreparer.PlaceHolder
public int getIndex()
Note, this method should generally not be used for MultiPlaceHolders as they usually have more than one index, however if there is at most one index, this method will behave like the parent class.
getIndex
in class QueryPreparer.PlaceHolder
UnsupportedOperationException
- if this method is called and
there is more than one indexpublic void setNull(int sqlType, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
setNull
in class QueryPreparer.PlaceHolder
SQLException
public void setInt(int value, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
setInt
in class QueryPreparer.PlaceHolder
SQLException
public void setLong(long value, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
setLong
in class QueryPreparer.PlaceHolder
SQLException
public void setBoolean(boolean value, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
setBoolean
in class QueryPreparer.PlaceHolder
SQLException
protected void setNonNullString(String value, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
setNonNullString
in class QueryPreparer.PlaceHolder
SQLException
public void setObject(Object value, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
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
QueryPreparer.PlaceHolder.setObject(Object,int,PreparedStatement)
with the correct SQL
type.setObject
in class QueryPreparer.PlaceHolder
SQLException
protected void setNonNullObject(Object value, int sqlType, PreparedStatement ps) throws SQLException
QueryPreparer.PlaceHolder
setNonNullObject
in class QueryPreparer.PlaceHolder
SQLException
Copyright © 2006–2021 OpenHMS. All rights reserved.