Class Update
- All Implemented Interfaces:
Closeable, AutoCloseable, Configurable<Update>
Used for INSERT, UPDATE, and DELETE statements
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal UpdateRegisters with the handle for cleaning when the handle is closed.voidclose()intexecute()Executes the statement, returning the update count.<R> Rexecute(ResultProducer<R> producer) Executes the update, returning the result obtained from the givenResultProducer.executeAndReturnGeneratedKeys(String... generatedKeyColumnNames) Execute the statement and returns any auto-generated keys.longExecutes the statement, returning the large update count.Returns the configuration registry associated with this object.final StatementContextReturns the statement context associated with this statement.final Handlevoidone()Methods inherited from class SqlStatement
bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindASCIIStream, bindASCIIStream, bindBean, bindBean, bindBeanList, bindBinaryStream, bindBinaryStream, bindBySqlType, bindBySqlType, bindByType, bindByType, bindByType, bindByType, bindByType, bindByType, bindFields, bindFields, bindList, bindList, bindList, bindList, bindList, bindList, bindList, bindMap, bindMethods, bindMethods, bindMethodsList, bindNamedArgumentFinder, bindNull, bindNull, bindNVarchar, bindNVarchar, bindPojo, bindPojo, bindPojo, bindPojo, bindPojo, bindPojo, cleanupHandleCommit, cleanupHandleRollback, defineList, defineList, defineNamedBindings, setQueryTimeout, toStringModifier and TypeMethodDescriptionfinal Updatebind(int position, boolean value) Bind an argument positionallyfinal Updatebind(int position, byte value) Bind an argument positionallyfinal Updatebind(int position, byte[] value) Bind an argument positionallyfinal Updatebind(int position, char value) Bind an argument positionallyfinal Updatebind(int position, double value) Bind an argument positionallyfinal Updatebind(int position, float value) Bind an argument positionallyfinal Updatebind(int position, int value) Bind an argument positionallyfinal Updatebind(int position, long value) Bind an argument positionallyfinal Updatebind(int position, short value) Bind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal Updatebind(int position, BigDecimal value) Bind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyfinal UpdateBind an argument positionallyUsed if you need to have some exotic parameter bound.final UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal Updatebind(String name, BigDecimal value) Bind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by namefinal UpdateBind an argument by nameUsed if you need to have some exotic parameter bound.final UpdateBind an Iterable as a SQL array.final UpdateBind a Java array as a SQL array, casting each element to a new type.final UpdateBind an Iterator as a SQL array.final <T> UpdatebindArray(int pos, T... array) Bind a Java array as a SQL array.final UpdateBind an Iterable as a SQL array.final UpdateBind a Java array as a SQL array, casting each element to a new type.final UpdateBind an Iterator as a SQL array.final <T> UpdateBind a Java array as a SQL array.final UpdatebindASCIIStream(int position, InputStream value, int length) Bind an argument positionallyfinal UpdatebindASCIIStream(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 UpdatebindBeanList(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 UpdatebindBinaryStream(int position, InputStream value, int length) Bind an argument positionallyfinal UpdatebindBinaryStream(String name, InputStream value, int length) Bind an argument by namefinal UpdatebindBySqlType(int position, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Typesvia PreparedStatement#setObject(int, Object, int)final UpdatebindBySqlType(String name, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Typesvia PreparedStatement#setObject(int, Object, int)final UpdatebindByType(int position, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final UpdatebindByType(int position, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final UpdatebindByType(int position, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the qualified type passed in.final UpdatebindByType(String name, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final UpdatebindByType(String name, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final UpdatebindByType(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 Updatefinal Updatefinal Updatefinal UpdatebindList(BiConsumer<SqlStatement, String> onEmpty, String key, Iterable<?> values) final UpdatebindList(BiConsumer<SqlStatement, String> onEmpty, String key, Object... values) final UpdatebindList(BiConsumer<SqlStatement, String> onEmpty, String key, Iterator<?> values) final UpdatebindList(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 UpdatebindMethodsList(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 UpdatebindNull(int position, int sqlType) Bind NULL to be set for a given argument.final UpdateBind NULL to be set for a given argument.final UpdatebindNVarchar(int position, String value) Bind aStringargument positionally, asNVARCHARtype.final UpdatebindNVarchar(String name, String value) Bind aStringargument by name, asNVARCHARtype.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.final UpdatedefineList(String key, Object... values) Define an attribute as the comma-separatedStringfrom the elements of thevaluesargument.final UpdatedefineList(String key, List<?> values) Define an attribute as the comma-separatedStringfrom the elements of thevaluesargument.Define all bound arguments that don't already have a definition with a boolean indicating their presence.setQueryTimeout(int seconds) Set the query timeout, in seconds, on the prepared statement.toString()Methods inherited from interface Configurable
addCustomizer, configure, define, getConfig, registerArgument, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerArrayType, registerCodecFactory, registerCollector, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlLogger, setSqlParser, setTemplateEngine, setTimingCollectorModifier and TypeMethodDescriptiondefault UpdateaddCustomizer(StatementCustomizer customizer) default <C extends JdbiConfig<C>>
UpdatePasses the configuration object of the given type to the configurer, then returns this object.default UpdateConvenience method forgetConfig(SqlStatements.class).define(key, value)default <C extends JdbiConfig<C>>
CGets the configuration object of the given type, associated with this object.default UpdateregisterArgument(ArgumentFactory factory) Convenience method forgetConfig(Arguments.class).register(factory)default UpdateregisterArgument(QualifiedArgumentFactory factory) Convenience method forgetConfig(Arguments.class).register(factory)default UpdateregisterArrayType(Class<?> elementType, String sqlTypeName) Convenience method forgetConfig(SqlArrayTypes.class).register(elementType, sqlTypeName)default <T> UpdateregisterArrayType(Class<T> elementType, String sqlTypeName, Function<T, ?> conversion) Convenience method for registering an array type asSqlArrayTypeFactory.of(Class, String, Function).default UpdateregisterArrayType(SqlArrayType<?> arrayType) Convenience method forgetConfig(SqlArrayTypes.class).register(arrayType)default UpdateregisterArrayType(SqlArrayTypeFactory factory) Convenience method forgetConfig(SqlArrayTypes.class).register(factory)default UpdateregisterCodecFactory(CodecFactory codecFactory) Convenience method to register aCodecFactory.default UpdateregisterCollector(Type collectionType, Collector<?, ?, ?> collector) Convenience method forgetConfig(JdbiCollectors.class).register(CollectorFactory.collectorFactory(collectionType, collector))default UpdateregisterCollector(CollectorFactory factory) Convenience method forgetConfig(JdbiCollectors.class).register(factory)default UpdateregisterColumnMapper(Type type, ColumnMapper<?> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default <T> UpdateregisterColumnMapper(GenericType<T> type, ColumnMapper<T> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default UpdateregisterColumnMapper(ColumnMapper<?> mapper) Convenience method forgetConfig(ColumnMappers.class).register(mapper)default UpdateregisterColumnMapper(ColumnMapperFactory factory) Convenience method forgetConfig(ColumnMappers.class).register(factory)default UpdateConvenience method forgetConfig(ColumnMappers.class).register(factory)default <T> UpdateregisterColumnMapper(QualifiedType<T> type, ColumnMapper<T> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default UpdateregisterExtension(ExtensionFactory factory) Convenience method forgetConfig(Extensions.class).register(factory)default UpdateregisterRowMapper(Type type, RowMapper<?> mapper) Convenience method forgetConfig(RowMappers.class).register(type, mapper)default <T> UpdateregisterRowMapper(GenericType<T> type, RowMapper<T> mapper) Convenience method forgetConfig(RowMappers.class).register(type, mapper)default UpdateregisterRowMapper(RowMapper<?> mapper) Convenience method forgetConfig(RowMappers.class).register(mapper)default UpdateregisterRowMapper(RowMapperFactory factory) Convenience method forgetConfig(RowMappers.class).register(factory)default UpdatesetMapKeyColumn(String keyColumn) Convenience method forgetConfig(MapEntryMappers.class).setKeyColumn(keyColumn)default UpdatesetMapValueColumn(String valueColumn) Convenience method forgetConfig(MapEntryMappers.class).setValueColumn(valueColumn)default UpdateConvenience method forgetConfig(SqlArrayTypes.class).setArgumentStrategy(strategy)default UpdatesetSqlLogger(SqlLogger sqlLogger) default UpdatesetSqlParser(SqlParser parser) Convenience method forgetConfig(SqlStatements.class).setSqlParser(rewriter)default UpdatesetTemplateEngine(TemplateEngine templateEngine) Convenience method forgetConfig(SqlStatements.class).setTemplateEngine(rewriter)default UpdatesetTimingCollector(TimingCollector collector) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
Update
-
Update
-
-
Method Details
-
one
public void one() -
execute
public int execute()Executes the statement, returning the update count.- Returns:
- the number of rows modified
-
executeLarge
public long executeLarge()Executes the statement, returning the large update count.- Returns:
- the number of rows modified as a long
-
execute
Executes the update, returning the result obtained from the givenResultProducer.- Type Parameters:
R- the result type- Parameters:
producer- the result producer.- Returns:
- value returned by the result producer.
-
executeAndReturnGeneratedKeys
Execute the statement and returns any auto-generated keys. This requires the JDBC driver to support theStatement.getGeneratedKeys()method.- Parameters:
generatedKeyColumnNames- optional list of generated key column names.- Returns:
- ResultBearing of generated keys
-
getHandle
-
getConfig
Description copied from interface:ConfigurableReturns the configuration registry associated with this object.- Specified by:
getConfigin 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.
-
attachToHandleForCleanup
Registers with the handle for cleaning when the handle is closed.
There are some situations where Statements need to be cleaned up to avoid resource leaks. This method registers the current Statement it with the Handle. If the statement or the context are cleaned by themselves, it will automatically unregister, so in normal operations, resources should not pool for cleanup with the Handle.- Since:
- 3.35.0
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
Configurable.setSqlLogger(SqlLogger)instead