public static class QueryPreparer.ListPlaceHolder 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 ListPlaceHolder may not be used in more than one place in the
query unless all the underlying PlaceHolders are instances of QueryPreparer.MultiPlaceHolder
.ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
Constructor and Description |
---|
ListPlaceHolder(QueryPreparer outer) |
Modifier and Type | Method and Description |
---|---|
QueryPreparer.MultiPlaceHolder |
addNewMultiPlaceHolder()
Adds a new MultiPlaceHolder to this list and returns it.
|
QueryPreparer.PlaceHolder |
addNewPlaceHolder()
Adds a new PlaceHolder to this list and returns it.
|
QueryPreparer.ListPlaceHolder |
addPlaceHolders(int size)
Adds the given number of PlaceHolders to this list.
|
QueryPreparer.ListPlaceHolder |
addStaticBooleans(boolean... values)
Adds StaticPlaceHolders for the given boolean values.
|
QueryPreparer.ListPlaceHolder |
addStaticBooleans(Iterable<? extends Boolean> values)
Adds StaticPlaceHolders for the given Boolean values.
|
QueryPreparer.ListPlaceHolder |
addStaticIntegers(int... values)
Adds StaticPlaceHolders for the given int values.
|
QueryPreparer.ListPlaceHolder |
addStaticIntegers(Iterable<? extends Integer> values)
Adds StaticPlaceHolders for the given Integer values.
|
QueryPreparer.ListPlaceHolder |
addStaticLongs(Iterable<? extends Long> values)
Adds StaticPlaceHolders for the given Long values.
|
QueryPreparer.ListPlaceHolder |
addStaticLongs(long... values)
Adds StaticPlaceHolders for the given long values.
|
QueryPreparer.ListPlaceHolder |
addStaticObjects(int sqlType,
Iterable<?> values)
Adds StaticPlaceHolders for the given Object values and given sql type.
|
QueryPreparer.ListPlaceHolder |
addStaticObjects(int sqlType,
Object... values)
Adds StaticPlaceHolders for the given Object values and given sql type.
|
QueryPreparer.ListPlaceHolder |
addStaticObjects(Iterable<?> values)
Adds StaticPlaceHolders for the given Object values.
|
QueryPreparer.ListPlaceHolder |
addStaticObjects(Object... values)
Adds StaticPlaceHolders for the given Object values.
|
QueryPreparer.StaticPlaceHolder |
addStaticPlaceHolder(QueryPreparer.StaticPlaceHolder ph)
Adds the given StaticPlaceHolder to this list and returns it.
|
QueryPreparer.ListPlaceHolder |
addStaticStrings(Iterable<? extends String> values)
Adds StaticPlaceHolders for the given String values.
|
QueryPreparer.ListPlaceHolder |
addStaticStrings(String... values)
Adds StaticPlaceHolders for the given String values.
|
void |
appendTo(AppendableExt app)
Appends this object to the given AppendableExt.
|
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 |
setBooleans(PreparedStatement ps,
boolean... values)
Calls setBoolean on the given PreparedStatement with the given values
for the positions of this PlaceHolder.
|
void |
setBooleans(PreparedStatement ps,
Iterable<? extends Boolean> values)
Calls setBoolean on the given PreparedStatement with the given values for
the positions of this PlaceHolder.
|
void |
setInts(PreparedStatement ps,
int... values)
Calls setInt on the given PreparedStatement with the given values for
the positions of this PlaceHolder.
|
void |
setInts(PreparedStatement ps,
Iterable<? extends Integer> values)
Calls setInt on the given PreparedStatement with the given values for
the positions of this PlaceHolder.
|
void |
setLongs(PreparedStatement ps,
Iterable<? extends Long> values)
Calls setLong on the given PreparedStatement with the given values for
the positions of this PlaceHolder.
|
void |
setLongs(PreparedStatement ps,
long... values)
Calls setLong on the given PreparedStatement with the given values
for the positions of this PlaceHolder.
|
void |
setNulls(int sqlType,
PreparedStatement ps)
Calls setNull on the given PreparedStatement with the given sql type
for the positions of this PlaceHolder.
|
void |
setObjects(int sqlType,
PreparedStatement ps,
Iterable<?> values)
Calls setObject on the given PreparedStatement with the given value and
the given sql type for the position of this PlaceHolder.
|
void |
setObjects(int sqlType,
PreparedStatement ps,
Object... values)
Calls setObject on the given PreparedStatement with the given values
and the given sql type for the positions of this PlaceHolder.
|
void |
setObjects(PreparedStatement ps,
Iterable<?> values)
Calls setObject on the given PreparedStatement with the given values
for the positions of this PlaceHolder.
|
void |
setObjects(PreparedStatement ps,
Object... values)
Calls setObject on the given PreparedStatement with the given values
for the positions of this PlaceHolder.
|
void |
setStrings(PreparedStatement ps,
Iterable<? extends String> values)
Calls setString on the given PreparedStatement with the given values
for the positions of this PlaceHolder.
|
void |
setStrings(PreparedStatement ps,
String... values)
Calls setString on the given PreparedStatement with the given values for
the positions of this PlaceHolder.
|
addIndex, collectSchemaObjects, getOuter, setBoolean, setBoolean, setInt, setInt, setLong, setLong, setNonNullObject, setNonNullString, setNull, setObject, setObject, setString
collectSchemaObjects, doValidate, toString
toString, toString
public ListPlaceHolder(QueryPreparer outer)
public boolean isInQuery()
QueryPreparer.PlaceHolder
true
if this PlaceHolder was used in the query,
false
otherwise.isInQuery
in class QueryPreparer.PlaceHolder
public int getIndex()
Note, this method should generally not be used for ListPlaceHolders 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 List<Integer> getIndexes()
getIndexes
in class QueryPreparer.PlaceHolder
public QueryPreparer.PlaceHolder addNewPlaceHolder()
public QueryPreparer.MultiPlaceHolder addNewMultiPlaceHolder()
public QueryPreparer.StaticPlaceHolder addStaticPlaceHolder(QueryPreparer.StaticPlaceHolder ph)
public QueryPreparer.ListPlaceHolder addPlaceHolders(int size)
public QueryPreparer.ListPlaceHolder addStaticStrings(String... values)
public QueryPreparer.ListPlaceHolder addStaticStrings(Iterable<? extends String> values)
public QueryPreparer.ListPlaceHolder addStaticLongs(long... values)
public QueryPreparer.ListPlaceHolder addStaticLongs(Iterable<? extends Long> values)
public QueryPreparer.ListPlaceHolder addStaticIntegers(int... values)
public QueryPreparer.ListPlaceHolder addStaticIntegers(Iterable<? extends Integer> values)
public QueryPreparer.ListPlaceHolder addStaticBooleans(boolean... values)
public QueryPreparer.ListPlaceHolder addStaticBooleans(Iterable<? extends Boolean> values)
public QueryPreparer.ListPlaceHolder addStaticObjects(Object... values)
public QueryPreparer.ListPlaceHolder addStaticObjects(Iterable<?> values)
public QueryPreparer.ListPlaceHolder addStaticObjects(int sqlType, Object... values)
public QueryPreparer.ListPlaceHolder addStaticObjects(int sqlType, Iterable<?> values)
public void setNulls(int sqlType, PreparedStatement ps) throws SQLException
SQLException
public void setInts(PreparedStatement ps, int... values) throws SQLException
SQLException
public void setInts(PreparedStatement ps, Iterable<? extends Integer> values) throws SQLException
null
, calls setNull with the sql type
INTEGER
.SQLException
public void setLongs(PreparedStatement ps, long... values) throws SQLException
SQLException
public void setLongs(PreparedStatement ps, Iterable<? extends Long> values) throws SQLException
null
, calls setNull with the sql type BIGINT
.SQLException
public void setBooleans(PreparedStatement ps, boolean... values) throws SQLException
SQLException
public void setBooleans(PreparedStatement ps, Iterable<? extends Boolean> values) throws SQLException
null
,
calls setNull with the sql type BOOLEAN
.SQLException
public void setStrings(PreparedStatement ps, String... values) throws SQLException
null
,
calls setNull with the sql type VARCHAR
.SQLException
public void setStrings(PreparedStatement ps, Iterable<? extends String> values) throws SQLException
null
, calls setNull with the sql type
VARCHAR
.SQLException
public void setObjects(PreparedStatement ps, Object... values) 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
setObjects(int,PreparedStatement,Object...)
with the correct SQL
type.SQLException
public void setObjects(PreparedStatement ps, Iterable<?> values) 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
setObjects(int,PreparedStatement,Iterable)
with the correct SQL
type.SQLException
public void setObjects(int sqlType, PreparedStatement ps, Object... values) throws SQLException
SQLException
public void setObjects(int sqlType, PreparedStatement ps, Iterable<?> values) throws SQLException
null
, calls setNull with the given sql type.SQLException
public final void appendTo(AppendableExt app) throws IOException
Appendee
appendTo
in interface Appendee
appendTo
in class QueryPreparer.PlaceHolder
app
- the AppendableExt to which this class should append itselfIOException
- if the append failsCopyright © 2006–2021 OpenHMS. All rights reserved.