public abstract class SqlStatement<This extends SqlStatement<This>> extends Object
Query and
Update. It defines most of the argument binding functions
used by its subclasses.| Modifier and Type | Method and Description |
|---|---|
This |
addCustomizer(StatementCustomizer customizer)
Provides a means for custom statement modification.
|
This |
bind(int position,
Argument argument)
Used if you need to have some exotic parameter bound.
|
This |
bind(int position,
BigDecimal value)
Bind an argument positionally
|
This |
bind(int position,
Blob value)
Bind an argument positionally
|
This |
bind(int position,
boolean value)
Bind an argument positionally
|
This |
bind(int position,
Boolean value)
Bind an argument positionally
|
This |
bind(int position,
byte value)
Bind an argument positionally
|
This |
bind(int position,
Byte value)
Bind an argument positionally
|
This |
bind(int position,
byte[] value)
Bind an argument positionally
|
This |
bind(int position,
char value)
Bind an argument positionally
|
This |
bind(int position,
Character value)
Bind an argument positionally
|
This |
bind(int position,
Clob value)
Bind an argument positionally
|
This |
bind(int position,
Date value)
Bind an argument positionally
|
This |
bind(int position,
Date value)
Bind an argument positionally
|
This |
bind(int position,
double value)
Bind an argument positionally
|
This |
bind(int position,
Double value)
Bind an argument positionally
|
This |
bind(int position,
float value)
Bind an argument positionally
|
This |
bind(int position,
Float value)
Bind an argument positionally
|
This |
bind(int position,
int value)
Bind an argument positionally
|
This |
bind(int position,
Integer value)
Bind an argument positionally
|
This |
bind(int position,
long value)
Bind an argument positionally
|
This |
bind(int position,
Long value)
Bind an argument positionally
|
This |
bind(int position,
Object value)
Bind an argument positionally
|
This |
bind(int position,
Reader value,
int length)
Bind an argument positionally
|
This |
bind(int position,
short value)
Bind an argument positionally
|
This |
bind(int position,
Short value)
Bind an argument positionally
|
This |
bind(int position,
String value)
Bind an argument positionally
|
This |
bind(int position,
Time value)
Bind an argument positionally
|
This |
bind(int position,
Timestamp value)
Bind an argument positionally
|
This |
bind(int position,
URL value)
Bind an argument positionally
|
This |
bind(String name,
Argument argument)
Used if you need to have some exotic parameter bound.
|
This |
bind(String name,
BigDecimal value)
Bind an argument by name
|
This |
bind(String name,
Blob value)
Bind an argument by name
|
This |
bind(String name,
boolean value)
Bind an argument by name
|
This |
bind(String name,
Boolean value)
Bind an argument by name
|
This |
bind(String name,
byte value)
Bind an argument by name
|
This |
bind(String name,
Byte value)
Bind an argument by name
|
This |
bind(String name,
byte[] value)
Bind an argument by name
|
This |
bind(String name,
char value)
Bind an argument by name
|
This |
bind(String name,
Character value)
Bind an argument by name
|
This |
bind(String name,
Clob value)
Bind an argument by name
|
This |
bind(String name,
Date value)
Bind an argument by name
|
This |
bind(String name,
Date value)
Bind an argument by name
|
This |
bind(String name,
double value)
Bind an argument by name
|
This |
bind(String name,
Double value)
Bind an argument by name
|
This |
bind(String name,
float value)
Bind an argument by name
|
This |
bind(String name,
Float value)
Bind an argument by name
|
This |
bind(String name,
int value)
Bind an argument by name
|
This |
bind(String name,
Integer value)
Bind an argument by name
|
This |
bind(String name,
long value)
Bind an argument by name
|
This |
bind(String name,
Long value)
Bind an argument by name
|
This |
bind(String name,
Object value)
Bind an argument by name
|
This |
bind(String name,
Reader value,
int length)
Bind an argument by name
|
This |
bind(String name,
short value)
Bind an argument by name
|
This |
bind(String name,
Short value)
Bind an argument by name
|
This |
bind(String name,
String value)
Bind an argument by name
|
This |
bind(String name,
Time value)
Bind an argument by name
|
This |
bind(String name,
Timestamp value)
Bind an argument by name
|
This |
bind(String name,
URL value)
Bind an argument by name
|
This |
bindASCIIStream(int position,
InputStream value,
int length)
Bind an argument positionally
|
This |
bindASCIIStream(String name,
InputStream value,
int length)
Bind an argument by name
|
This |
bindBean(Object bean)
Binds named parameters from JavaBean properties on the argument.
|
This |
bindBean(String prefix,
Object bean)
Binds named parameters from JavaBean properties on the bean argument, with the given prefix.
|
This |
bindBeanList(String key,
List<?> values,
List<String> propertyNames)
Bind a parameter for each value in the given list * number of property names,
and defines an attribute as the comma-separated list of parameter references (using colon prefix).
|
This |
bindBinaryStream(int position,
InputStream value,
int length)
Bind an argument positionally
|
This |
bindBinaryStream(String name,
InputStream value,
int length)
Bind an argument by name
|
This |
bindBySqlType(int position,
Object value,
int sqlType)
Bind a value using a specific type from
java.sql.Types via
PreparedStatement#setObject(int, Object, int) |
This |
bindBySqlType(String name,
Object value,
int sqlType)
Bind a value using a specific type from
java.sql.Types via
PreparedStatement#setObject(int, Object, int) |
This |
bindByType(int position,
Object value,
GenericType<?> argumentType)
Bind an argument dynamically by the generic type passed in.
|
This |
bindByType(int position,
Object value,
Type argumentType)
Bind an argument dynamically by the type passed in.
|
This |
bindByType(String name,
Object value,
GenericType<?> argumentType)
Bind an argument dynamically by the generic type passed in.
|
This |
bindByType(String name,
Object value,
Type argumentType)
Bind an argument dynamically by the type passed in.
|
This |
bindFields(Object object)
Binds public fields of the specified object as arguments for the query.
|
This |
bindFields(String prefix,
Object object)
Binds public fields of the specified object as arguments for the query.
|
This |
bindList(String key,
List<?> values)
Bind a parameter for each value in the given list, and defines an attribute as the comma-separated list of
parameter references (using colon prefix).
|
This |
bindList(String key,
Object... values)
Bind a parameter for each value in the given vararg array, and defines an attribute as the comma-separated list
of parameter references (using colon prefix).
|
This |
bindMap(Map<String,?> map)
Binds named parameters from a map of String to Object instances
|
This |
bindMethods(Object object)
Binds methods with no parameters on the argument.
|
This |
bindMethods(String prefix,
Object object)
Binds methods with no parameters on the argument, with the given prefix.
|
This |
bindNamedArgumentFinder(NamedArgumentFinder namedArgumentFinder)
Binds a new
NamedArgumentFinder. |
This |
bindNull(int position,
int sqlType)
Bind NULL to be set for a given argument.
|
This |
bindNull(String name,
int sqlType)
Bind NULL to be set for a given argument.
|
This |
cleanupHandleCommit()
Transfer ownership of the handle to the statement: when the statement is closed,
commit the handle's transaction (if one exists) and close the handle.
|
This |
cleanupHandleRollback()
When the statement is closed, roll it back then close the owning Handle.
|
void |
close() |
This |
defineList(String key,
List<?> values)
Define an attribute as the comma-separated
String from the elements of the values argument. |
This |
defineList(String key,
Object... values)
Define an attribute as the comma-separated
String from the elements of the values argument. |
protected Binding |
getBinding() |
ConfigRegistry |
getConfig()
Returns the configuration registry associated with this object.
|
StatementContext |
getContext() |
Handle |
getHandle() |
protected String |
getSql() |
This |
setQueryTimeout(int seconds)
Set the query timeout, in seconds, on the prepared statement
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconfigure, define, getConfig, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlParser, setTemplateEngine, setTimingCollectorpublic This bind(int position, Argument argument)
position - position to bindBinaryStream this argument, starting at 0argument - exotic argument factorypublic final This bind(int position, BigDecimal value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Blob value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, boolean value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Boolean value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, byte value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Byte value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, byte[] value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, char value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Character value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Clob value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Date value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Date value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, double value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Double value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, float value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Float value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, int value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Integer value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, long value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Long value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Object value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Reader value, int length)
position - position to bind the parameter at, starting at 0value - to bindlength - number of characters to readpublic final This bind(int position, short value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Short value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, String value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Time value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, Timestamp value)
position - position to bind the parameter at, starting at 0value - to bindpublic final This bind(int position, URL value)
position - position to bind the parameter at, starting at 0value - to bindpublic This bind(String name, Argument argument)
name - name to bindBinaryStream this argumentargument - exotic argument factorypublic final This bind(String name, BigDecimal value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Blob value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, boolean value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Boolean value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, byte value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Byte value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, byte[] value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, char value)
name - name to bind the parameter tovalue - to bindpublic final This bind(String name, Character value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Clob value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Date value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Date value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, double value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Double value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, float value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Float value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, int value)
name - name to bind the parameter tovalue - to bindpublic final This bind(String name, Integer value)
name - name to bind the parameter tovalue - to bindpublic final This bind(String name, long value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Long value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Object value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Reader value, int length)
name - token name to bind the parameter tovalue - to bindlength - number of characters to readpublic final This bind(String name, short value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Short value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, String value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Time value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, Timestamp value)
name - token name to bind the parameter tovalue - to bindpublic final This bind(String name, URL value)
name - token name to bind the parameter tovalue - to bindpublic final This bindASCIIStream(int position, InputStream value, int length)
position - position to bind the parameter at, starting at 0value - to bindlength - how long is the stream being bound?public final This bindASCIIStream(String name, InputStream value, int length)
name - token name to bind the parameter tovalue - to bindlength - bytes to read from valuepublic This bindBean(Object bean)
bean - source of named parameter values to use as argumentspublic This bindBean(String prefix, Object bean)
foo applied to a bean property bar will be bound as foo.bar.prefix - a prefix to apply to all property names.bean - source of named parameter values to use as argumentspublic final This bindBeanList(String key, List<?> values, List<String> propertyNames) throws UnableToCreateStatementException
Examples:
List<ThingKey> thingKeys = ...
List<Thing> things = handle.createQuery("select * from things where (id, foo) in (<thingKeys>)")
.bindBeanList("thingKeys", thingKeys, Arrays.asList("id", "foo"))
.mapTo(Contact.class)
.list();
key - attribute namevalues - list of values that will be comma-spliced into the defined attribute value.propertyNames - list of properties that will be invoked on the values.IllegalArgumentException - if the list of values or properties is empty.UnableToCreateStatementException - If a property can't be found on an value or we can't find a Argument for it.public final This bindBinaryStream(int position, InputStream value, int length)
position - position to bind the parameter at, starting at 0value - to bindlength - the number of bytes in the stream.public final This bindBinaryStream(String name, InputStream value, int length)
name - token name to bind the parameter tovalue - to bindlength - bytes to read from valuepublic final This bindBySqlType(int position, Object value, int sqlType)
java.sql.Types via
PreparedStatement#setObject(int, Object, int)position - position to bind NULL to, starting at 0value - Value to bindsqlType - The sqlType from java.sql.Typespublic final This bindBySqlType(String name, Object value, int sqlType)
java.sql.Types via
PreparedStatement#setObject(int, Object, int)name - Named parameter to bind atvalue - Value to bindsqlType - The sqlType from java.sql.Typespublic final This bindByType(int position, Object value, GenericType<?> argumentType)
position - position to bind the parameter at, starting at 0value - to bindargumentType - type token for value argumentpublic final This bindByType(int position, Object value, Type argumentType)
position - position to bind the parameter at, starting at 0value - to bindargumentType - type for value argumentpublic final This bindByType(String name, Object value, GenericType<?> argumentType)
name - token name to bind the parameter tovalue - to bindargumentType - type token for value argumentpublic final This bindByType(String name, Object value, Type argumentType)
name - token name to bind the parameter tovalue - to bindargumentType - type for value argumentpublic This bindFields(Object object)
object - source of the public fields to bind.public This bindFields(String prefix, Object object)
prefix - a prefix to apply to all field names.object - source of the public fields to bind.public final This bindList(String key, List<?> values)
Examples:
List<String> columnNames = Arrays.asList("id", "name", "created_on");
List<Object> values = Arrays.asList(1, "Alice", LocalDate.now());
handle.createUpdate("insert into things (<columnNames>) values (<values>)")
.defineList("columnNames", columnNames)
.bindList("values", values)
.execute();
List<Integer> ids = Arrays.asList(1, 2, 3);
List<Thing> things = handle.createQuery("select * from things where id in (<ids>)")
.bindList("ids", ids)
.mapTo(Contact.class)
.list();
key - attribute namevalues - list of values that will be comma-spliced into the defined attribute value.IllegalArgumentException - if the list is empty.public final This bindList(String key, Object... values)
Examples:
handle.createUpdate("insert into things (<columnNames>) values (<values>)")
.defineList("columnNames", "id", "name", "created_on")
.bindList("values", 1, "Alice", LocalDate.now())
.execute();
List<Thing> things = handle.createQuery("select * from things where id in (<ids>)")
.bindList("ids", 1, 2, 3)
.mapTo(Contact.class)
.list();
key - attribute namevalues - vararg values that will be comma-spliced into the defined attribute value.IllegalArgumentException - if the vararg array is empty.public This bindMap(Map<String,?> map)
map - map where keys are matched to named parameters in order to bind arguments.
Can be null, in which case the binding has no effect.public This bindMethods(Object object)
object - source of methods to use as argumentspublic This bindMethods(String prefix, Object object)
prefix - a prefix to apply to all property names.object - source of methods to use as argumentspublic This bindNamedArgumentFinder(NamedArgumentFinder namedArgumentFinder)
NamedArgumentFinder.namedArgumentFinder - A NamedArgumentFinder to bind. Can be null.public final This bindNull(int position, int sqlType)
position - position to bind NULL to, starting at 0sqlType - The sqlType must be set and is a value from java.sql.Typespublic final This bindNull(String name, int sqlType)
name - Named parameter to bind tosqlType - The sqlType must be set and is a value from java.sql.Typespublic This cleanupHandleCommit()
public This cleanupHandleRollback()
public final This defineList(String key, List<?> values)
String from the elements of the values argument.
Examples:
List<String> columnNames = Arrays.asList("id", "name", "created_on");
List<Object> values = Arrays.asList(1, "Alice", LocalDate.now());
handle.createUpdate("insert into things (<columnNames>) values (<values>)")
.defineList("columnNames", columnNames)
.bindList("values", 1, values)
.execute();
List<String> columnNames = Arrays.asList("id", "name", "created_on");
List<Thing> things = handle.createQuery("select <columnNames> from things")
.bindList("columnNames", columnNames)
.mapTo(Contact.class)
.list();
key - attribute namevalues - list of values that will be comma-spliced into the defined attribute value.IllegalArgumentException - if the list is empty, or contains any null elements.public final This defineList(String key, Object... values)
String from the elements of the values argument.
Examples:
handle.createUpdate("insert into things (<columnNames>) values (<values>)")
.defineList("columnNames", "id", "name", "created_on")
.bindList("values", 1, "Alice", LocalDate.now())
.execute();
List<Thing> things = handle.createQuery("select <columnNames> from things")
.bindList("columnNames", "id", "name", "created_on")
.mapTo(Contact.class)
.list();
key - attribute namevalues - vararg values that will be comma-spliced into the defined attribute value.IllegalArgumentException - if the vararg array is empty, or contains any null elements.protected Binding getBinding()
protected String getSql()
public This setQueryTimeout(int seconds)
seconds - number of seconds before timing outpublic final This addCustomizer(StatementCustomizer customizer)
Query.setMaxRows(int)customizer - instance to be used to customize a statementpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic ConfigRegistry getConfig()
ConfigurablegetConfig in interface Configurable<This>public final StatementContext getContext()
public Handle getHandle()
Copyright © 2017. All rights reserved.