Package org.jdbi.v3.core.statement
Class SqlStatements
java.lang.Object
org.jdbi.v3.core.statement.SqlStatements
- All Implemented Interfaces:
JdbiConfig<SqlStatements>
Configuration holder for
SqlStatement
s.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddContextListener
(StatementContextListener listener) addCustomizer
(StatementCustomizer customizer) Provides a means for custom statement modification.Returns a copy of this configuration object.Define an attribute forStatementContext
for statements executed by Jdbi.Defines attributes for each key/value pair in the Map.getAttribute
(String key) Obtain the value of an attributeReturns the attributes which will be applied toSQL statements
created by Jdbi.Returns theTemplateEngine
which renders the SQL template.Deprecated.boolean
setQueryTimeout
(Integer seconds) Jdbi does not implement its own timeout mechanism: it simply callsStatement.setQueryTimeout(int)
, leaving timeout handling to your jdbc driver.setSqlLogger
(SqlLogger sqlLogger) setSqlParser
(SqlParser sqlParser) Sets theSqlParser
used to parse parameters in SQL statements executed by Jdbi.setTemplateCache
(com.github.benmanes.caffeine.cache.Caffeine<Object, Object> caffeineSpec) Sets the Caffeine cache used to avoid repeatedly parsing SQL statements.setTemplateEngine
(TemplateEngine templateEngine) Sets theTemplateEngine
used to render SQL for allSQL statements
executed by Jdbi.setTimingCollector
(TimingCollector timingCollector) Deprecated.setUnusedBindingAllowed
(boolean unusedBindingAllowed) Sets whether or not an exception should be thrown when any arguments are given to a query but not actually used in it.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jdbi.v3.core.config.JdbiConfig
setRegistry
-
Constructor Details
-
SqlStatements
public SqlStatements()
-
-
Method Details
-
define
Define an attribute forStatementContext
for statements executed by Jdbi.- Parameters:
key
- the key for the attributevalue
- the value for the attribute- Returns:
- this
-
defineMap
Defines attributes for each key/value pair in the Map.- Parameters:
values
- map of attributes to define.- Returns:
- this
-
getAttribute
Obtain the value of an attribute- Parameters:
key
- the name of the attribute- Returns:
- the value of the attribute
-
getAttributes
Returns the attributes which will be applied toSQL statements
created by Jdbi.- Returns:
- the defined attributes.
-
addCustomizer
Provides a means for custom statement modification. Common customizations have their own methods, such asQuery.setMaxRows(int)
- Parameters:
customizer
- instance to be used to customize a statement- Returns:
- this
-
addContextListener
-
getTemplateEngine
Returns theTemplateEngine
which renders the SQL template.- Returns:
- the template engine which renders the SQL template prior to parsing parameters.
-
setTemplateEngine
Sets theTemplateEngine
used to render SQL for allSQL statements
executed by Jdbi. The default engine replaces<name>
-style tokens with attributesdefined
on the statement context.- Parameters:
templateEngine
- the new template engine.- Returns:
- this
-
setTemplateCache
@Beta public SqlStatements setTemplateCache(com.github.benmanes.caffeine.cache.Caffeine<Object, Object> caffeineSpec) Sets the Caffeine cache used to avoid repeatedly parsing SQL statements.- Parameters:
caffeineSpec
- the cache builder to use to cache parsed SQL- Returns:
- this
-
getSqlParser
-
setSqlParser
Sets theSqlParser
used to parse parameters in SQL statements executed by Jdbi. The default parses colon-prefixed named parameter tokens, e.g.:name
.- Parameters:
sqlParser
- the new SQL parser.- Returns:
- this
-
getTimingCollector
Deprecated.usegetSqlLogger()
instead- Returns:
- the timing collector
-
setTimingCollector
Deprecated.Sets theTimingCollector
used to collect timing about theSQL statements
executed by Jdbi. The default collector does nothing.- Parameters:
timingCollector
- the new timing collector- Returns:
- this
-
getSqlLogger
-
setSqlLogger
-
getQueryTimeout
-
setQueryTimeout
Jdbi does not implement its own timeout mechanism: it simply callsStatement.setQueryTimeout(int)
, leaving timeout handling to your jdbc driver.- Parameters:
seconds
- the time in seconds to wait for a query to complete; 0 to disable the timeout; null to leave it at defaults (i.e. Jdbi will not callsetQueryTimeout(int)
)- Returns:
- this
-
isUnusedBindingAllowed
public boolean isUnusedBindingAllowed() -
setUnusedBindingAllowed
Sets whether or not an exception should be thrown when any arguments are given to a query but not actually used in it. Unused bindings tend to be bugs or oversights, but are not always. Defaults to false: unused bindings are not allowed.- Parameters:
unusedBindingAllowed
- the new setting- Returns:
- this
- See Also:
-
createCopy
Description copied from interface:JdbiConfig
Returns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.- Specified by:
createCopy
in interfaceJdbiConfig<SqlStatements>
- Returns:
- a copy of this configuration object.
-
getSqlLogger()
instead