Package org.jdbi.v3.core.statement
Class SqlStatement<This extends SqlStatement<This>>
java.lang.Object
org.jdbi.v3.core.statement.SqlStatement<This>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Configurable<This>
- Direct Known Subclasses:
Call
,PreparedBatch
,Query
,Script
,Update
This class provides the common functions between
Query
and
Update
. It defines most of the argument binding functions
used by its subclasses.-
Method Summary
Modifier and TypeMethodDescriptionfinal This
bind
(int position, boolean value) Bind an argument positionallyfinal This
bind
(int position, byte value) Bind an argument positionallyfinal This
bind
(int position, byte[] value) Bind an argument positionallyfinal This
bind
(int position, char value) Bind an argument positionallyfinal This
bind
(int position, double value) Bind an argument positionallyfinal This
bind
(int position, float value) Bind an argument positionallyfinal This
bind
(int position, int value) Bind an argument positionallyfinal This
bind
(int position, long value) Bind an argument positionallyfinal This
bind
(int position, short value) Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
bind
(int position, BigDecimal value) Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyfinal This
Bind an argument positionallyUsed if you need to have some exotic parameter bound.final This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
bind
(String name, BigDecimal value) Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by namefinal This
Bind an argument by nameUsed if you need to have some exotic parameter bound.final This
Bind an Iterable as a SQL array.final This
Bind a Java array as a SQL array, casting each element to a new type.final This
Bind an Iterator as a SQL array.final <T> This
bindArray
(int pos, T... array) Bind a Java array as a SQL array.final This
Bind an Iterable as a SQL array.final This
Bind a Java array as a SQL array, casting each element to a new type.final This
Bind an Iterator as a SQL array.final <T> This
Bind a Java array as a SQL array.final This
bindASCIIStream
(int position, InputStream value, int length) Bind an argument positionallyfinal This
bindASCIIStream
(String name, InputStream value, int length) Bind an argument by nameBinds named parameters from JavaBean properties on the argument.Binds named parameters from JavaBean properties on the bean argument, with the given prefix.final 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).final This
bindBinaryStream
(int position, InputStream value, int length) Bind an argument positionallyfinal This
bindBinaryStream
(String name, InputStream value, int length) Bind an argument by namefinal This
bindBySqlType
(int position, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Types
via PreparedStatement#setObject(int, Object, int)final This
bindBySqlType
(String name, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Types
via PreparedStatement#setObject(int, Object, int)final This
bindByType
(int position, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final This
bindByType
(int position, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final This
bindByType
(int position, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the qualified type passed in.final This
bindByType
(String name, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final This
bindByType
(String name, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final This
bindByType
(String name, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the type passed in.bindFields
(Object object) Binds public fields of the specified object as arguments for the query.bindFields
(String prefix, Object object) Binds public fields of the specified object as arguments for the query.final This
final This
final This
final This
bindList
(BiConsumer<SqlStatement, String> onEmpty, String key, Iterable<?> values) final This
bindList
(BiConsumer<SqlStatement, String> onEmpty, String key, Object... values) final This
bindList
(BiConsumer<SqlStatement, String> onEmpty, String key, Iterator<?> values) final This
bindList
(BiConsumer<SqlStatement, String> onEmpty, 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).Binds named parameters from a map of String to Object instancesbindMethods
(Object object) Binds methods with no parameters on the argument.bindMethods
(String prefix, Object object) Binds methods with no parameters on the argument, with the given prefix.final This
bindMethodsList
(String key, Iterable<?> values, List<String> methodNames) For each value given, create a tuple by invoking each given method in order, and bind the tuple into aVALUES (...)
format insert clause.bindNamedArgumentFinder
(NamedArgumentFinder namedArgumentFinder) Binds a newNamedArgumentFinder
.final This
bindNull
(int position, int sqlType) Bind NULL to be set for a given argument.final This
Bind NULL to be set for a given argument.final This
bindNVarchar
(int position, String value) Bind aString
argument positionally, asNVARCHAR
type.final This
bindNVarchar
(String name, String value) Bind aString
argument by name, asNVARCHAR
type.Binds named parameters from object properties on the argument.Binds named parameters from object properties on the argument.bindPojo
(Object pojo, GenericType<?> type) Binds named parameters from object properties on the argument.Binds named parameters from object properties on the bean argument, with the given prefix.Binds named parameters from object properties on the bean argument, with the given prefix.bindPojo
(String prefix, Object pojo, GenericType<?> type) Binds named parameters from object properties on the bean argument, with the given prefix.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.When the statement is closed, roll it back then close the owning Handle.void
close()
final This
defineList
(String key, Object... values) Define an attribute as the comma-separatedString
from the elements of thevalues
argument.final This
defineList
(String key, List<?> values) Define an attribute as the comma-separatedString
from the elements of thevalues
argument.Define all bound arguments that don't already have a definition with a boolean indicating their presence.Returns the configuration registry associated with this object.final StatementContext
Returns the statement context associated with this statement.final Handle
setQueryTimeout
(int seconds) Set the query timeout, in seconds, on the prepared statement.toString()
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jdbi.v3.core.config.Configurable
addCustomizer, configure, define, getConfig, registerArgument, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerArrayType, registerCodecFactory, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlLogger, setSqlParser, setTemplateEngine
-
Method Details
-
setQueryTimeout
Set the query timeout, in seconds, on the prepared statement.- Parameters:
seconds
- number of seconds before timing out- Returns:
- the same Query instance
-
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.- Returns:
- this
-
cleanupHandleRollback
When the statement is closed, roll it back then close the owning Handle.- Returns:
- this
-
bind
Used if you need to have some exotic parameter bound.- Parameters:
position
- position to bindBinaryStream this argument, starting at 0argument
- exotic argument factory- Returns:
- the same Query instance
-
bind
Used if you need to have some exotic parameter bound.- Parameters:
name
- name to bindBinaryStream this argumentargument
- exotic argument factory- Returns:
- the same Query instance
-
bindBean
Binds named parameters from JavaBean properties on the argument.- Parameters:
bean
- source of named parameter values to use as arguments- Returns:
- modified statement
-
bindBean
Binds named parameters from JavaBean properties on the bean argument, with the given prefix. Example: the prefixfoo
applied to a bean propertybar
will be bound asfoo.bar
.- Parameters:
prefix
- a prefix to apply to all property names.bean
- source of named parameter values to use as arguments- Returns:
- modified statement
-
bindPojo
Binds named parameters from object properties on the argument. The type must have been registered with pojo type mapping functionality first, usually by a plugin or configuration.- Parameters:
pojo
- source of named parameter values to use as arguments- Returns:
- modified statement
- See Also:
-
bindPojo
Binds named parameters from object properties on the bean argument, with the given prefix. The type must have been registered with pojo type mapping functionality first, usually by a plugin or configuration.- Parameters:
prefix
- a prefix to apply to all property names.pojo
- source of named parameter values to use as arguments- Returns:
- modified statement
- See Also:
-
bindPojo
Binds named parameters from object properties on the argument. The type must have been registered with pojo type mapping functionality first, usually by a plugin or configuration.- Parameters:
pojo
- source of named parameter values to use as argumentstype
- the static, possibly generic type of the pojo- Returns:
- modified statement
- See Also:
-
bindPojo
Binds named parameters from object properties on the bean argument, with the given prefix. The type must have been registered with pojo type mapping functionality first, usually by a plugin or configuration.- Parameters:
prefix
- a prefix to apply to all property names.pojo
- source of named parameter values to use as argumentstype
- the static, possibly generic type of the pojo- Returns:
- modified statement
- See Also:
-
bindPojo
Binds named parameters from object properties on the argument. The type must have been registered with pojo type mapping functionality first, usually by a plugin or configuration.- Parameters:
pojo
- source of named parameter values to use as argumentstype
- the static generic type of the pojo- Returns:
- modified statement
- See Also:
-
bindPojo
Binds named parameters from object properties on the bean argument, with the given prefix. The type must have been registered with pojo type mapping functionality first, usually by a plugin or configuration.- Parameters:
prefix
- a prefix to apply to all property names.pojo
- source of named parameter values to use as argumentstype
- the static generic type of the pojo- Returns:
- modified statement
- See Also:
-
bindFields
Binds public fields of the specified object as arguments for the query.- Parameters:
object
- source of the public fields to bind.- Returns:
- modified statement
-
bindFields
Binds public fields of the specified object as arguments for the query.- Parameters:
prefix
- a prefix to apply to all field names.object
- source of the public fields to bind.- Returns:
- modified statement
-
bindMethods
Binds methods with no parameters on the argument.- Parameters:
object
- source of methods to use as arguments- Returns:
- modified statement
-
bindMethods
Binds methods with no parameters on the argument, with the given prefix.- Parameters:
prefix
- a prefix to apply to all property names.object
- source of methods to use as arguments- Returns:
- modified statement
-
bindMap
Binds named parameters from a map of String to Object instances- Parameters:
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.- Returns:
- modified statement
-
bindNamedArgumentFinder
Binds a newNamedArgumentFinder
.- Parameters:
namedArgumentFinder
- A NamedArgumentFinder to bind. Can be null.- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bindNVarchar
Bind aString
argument positionally, asNVARCHAR
type.- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bindNVarchar
Bind aString
argument by name, asNVARCHAR
type.- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bindASCIIStream
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bindlength
- how long is the stream being bound?- Returns:
- the same Query instance
-
bindASCIIStream
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bindlength
- bytes to read from value- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bindBinaryStream
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bindlength
- the number of bytes in the stream.- Returns:
- the same Query instance
-
bindBinaryStream
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bindlength
- bytes to read from value- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bindlength
- number of characters to read- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bindlength
- number of characters to read- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument positionally- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bind- Returns:
- the same Query instance
-
bind
Bind an argument by name- Parameters:
name
- token name to bind the parameter tovalue
- to bind- Returns:
- the same Query instance
-
bindByType
Bind an argument dynamically by the type passed in.- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bindargumentType
- type for value argument- Returns:
- the same Query instance
-
bindByType
Bind an argument dynamically by the generic type passed in.- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bindargumentType
- type token for value argument- Returns:
- the same Query instance
-
bindByType
Bind an argument dynamically by the qualified type passed in.- Parameters:
position
- position to bind the parameter at, starting at 0value
- to bindargumentType
- type token for value argument- Returns:
- the same Query instance
-
bindByType
Bind an argument dynamically by the type passed in.- Parameters:
name
- token name to bind the parameter tovalue
- to bindargumentType
- type for value argument- Returns:
- the same Query instance
-
bindByType
Bind an argument dynamically by the generic type passed in.- Parameters:
name
- token name to bind the parameter tovalue
- to bindargumentType
- type token for value argument- Returns:
- the same Query instance
-
bindByType
Bind an argument dynamically by the type passed in.- Parameters:
name
- token name to bind the parameter tovalue
- to bindargumentType
- type for value argument- Returns:
- the same Query instance
-
bindArray
Bind a Java array as a SQL array. Usually you can justbind(int, Object)
an array, but this method allows varargs.- Type Parameters:
T
- the array element type- Parameters:
name
- the name of the parameter to bindarray
- the array to bind- Returns:
- this Query
-
bindArray
Bind a Java array as a SQL array. Usually you can justbind(int, Object)
an array, but this method allows varargs.- Type Parameters:
T
- the array element type- Parameters:
pos
- the position of the parameter to bindarray
- the array to bind- Returns:
- this Query
-
bindArray
Bind a Java array as a SQL array, casting each element to a new type.- Parameters:
name
- the name of the parameter to bindelementType
- the array element typearray
- the array to bind- Returns:
- this Query
-
bindArray
Bind a Java array as a SQL array, casting each element to a new type.- Parameters:
pos
- the position of the parameter to bindelementType
- the array element typearray
- the array to bind- Returns:
- this Query
-
bindArray
Bind an Iterable as a SQL array.- Parameters:
name
- the name of the parameter to bindelementType
- the element type of the Iterableiterable
- the iterable to bind as an array- Returns:
- this Query
-
bindArray
Bind an Iterable as a SQL array.- Parameters:
pos
- the position of the parameter to bindelementType
- the element type of the Iterableiterable
- the iterable to bind as an array- Returns:
- this Query
-
bindArray
Bind an Iterator as a SQL array.- Parameters:
name
- the name of the parameter to bindelementType
- the element type of the Iterableiterator
- the iterator to bind as an array- Returns:
- this Query
-
bindArray
Bind an Iterator as a SQL array.- Parameters:
pos
- the position of the parameter to bindelementType
- the element type of the Iteratoriterator
- the Iterator to bind as an array- Returns:
- this Query
-
bindNull
Bind NULL to be set for a given argument.- Parameters:
name
- Named parameter to bind tosqlType
- The sqlType must be set and is a value fromjava.sql.Types
- Returns:
- the same statement instance
-
bindNull
Bind NULL to be set for a given argument.- Parameters:
position
- position to bind NULL to, starting at 0sqlType
- The sqlType must be set and is a value fromjava.sql.Types
- Returns:
- the same statement instance
-
bindBySqlType
Bind a value using a specific type fromjava.sql.Types
via PreparedStatement#setObject(int, Object, int)- Parameters:
name
- Named parameter to bind atvalue
- Value to bindsqlType
- The sqlType from java.sql.Types- Returns:
- self
-
bindBySqlType
Bind a value using a specific type fromjava.sql.Types
via PreparedStatement#setObject(int, Object, int)- Parameters:
position
- position to bind NULL to, starting at 0value
- Value to bindsqlType
- The sqlType from java.sql.Types- Returns:
- self
-
bindList
- Parameters:
key
- attribute namevalues
- vararg values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the vararg array is empty.
-
bindList
- Parameters:
onEmpty
- handler for null/empty vararg arraykey
- attribute namevalues
- vararg values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the vararg array is empty.- See Also:
-
bindList
- Parameters:
key
- attribute namevalues
- iterable values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the iterable is empty.
-
bindList
- Parameters:
onEmpty
- handler for null/empty listkey
- attribute namevalues
- iterable values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the iterable is empty.- See Also:
-
bindList
- Parameters:
key
- attribute namevalues
- iterator of values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the iterator is empty.
-
bindList
- Parameters:
onEmpty
- handler for null/empty listkey
- attribute namevalues
- iterator of values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the iterator is empty.- See Also:
-
bindList
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).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();
- Parameters:
onEmpty
- handler for null/empty listkey
- attribute namevalues
- list of values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the list is empty.- See Also:
-
bindBeanList
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). Used to create query similar to: select * from things where (id, foo) in ((1,'abc'),(2,'def'),(3,'ghi'))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();
- Parameters:
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.- Returns:
- this
- Throws:
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.
-
bindMethodsList
For each value given, create a tuple by invoking each given method in order, and bind the tuple into aVALUES (...)
format insert clause.- Parameters:
key
- attribute namevalues
- list of values that will be comma-spliced into the defined attribute valuemethodNames
- list of methods that will be invoked on the values- Returns:
- this
- Throws:
IllegalArgumentException
- if the list of values or properties is empty.UnableToCreateStatementException
- if the method cannot be found
-
defineList
Define an attribute as the comma-separatedString
from the elements of thevalues
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();
- Parameters:
key
- attribute namevalues
- vararg values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the vararg array is empty, or contains any null elements.
-
defineList
Define an attribute as the comma-separatedString
from the elements of thevalues
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();
- Parameters:
key
- attribute namevalues
- list of values that will be comma-spliced into the defined attribute value.- Returns:
- this
- Throws:
IllegalArgumentException
- if the list is empty, or contains any null elements.
-
defineNamedBindings
Define all bound arguments that don't already have a definition with a boolean indicating their presence. Useful to easily template optional properties of pojos or beans like<if(property)>property = :property<endif>
.- Returns:
- this
-
toString
-
getHandle
-
getConfig
Description copied from interface:Configurable
Returns the configuration registry associated with this object.- Specified by:
getConfig
in interfaceConfigurable<This>
- Returns:
- the configuration registry associated with this object.
-
getContext
Returns the statement context associated with this statement.- Returns:
- the statement context associated with this statement.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-