spring-framework / org.springframework.jdbc.core.simple / SimpleJdbcInsert

SimpleJdbcInsert

open class SimpleJdbcInsert : AbstractJdbcInsert, SimpleJdbcInsertOperations

A SimpleJdbcInsert is a multi-threaded, reusable object providing easy insert capabilities for a table. It provides meta data processing to simplify the code needed to construct a basic insert statement. All you need to provide is the name of the table and a Map containing the column names and the column values.

The meta data processing is based on the DatabaseMetaData provided by the JDBC driver. As long as the JDBC driver can provide the names of the columns for a specified table than we can rely on this auto-detection feature. If that is not the case, then the column names must be specified explicitly.

The actual insert is being handled using Spring's org.springframework.jdbc.core.JdbcTemplate.

Many of the configuration methods return the current instance of the SimpleJdbcInsert to provide the ability to chain multiple ones together in a "fluent" interface style.

Author
Thomas Risberg

Since
2.5

See Also
java.sql.DatabaseMetaDataorg.springframework.jdbc.core.JdbcTemplate

Constructors

<init>

SimpleJdbcInsert(dataSource: DataSource)

Constructor that takes one parameter with the JDBC DataSource to use when creating the JdbcTemplate.

SimpleJdbcInsert(jdbcTemplate: JdbcTemplate)

Alternative Constructor that takes one parameter with the JdbcTemplate to be used.

Functions

execute

open fun execute(args: MutableMap<String, *>): Int
open fun execute(parameterSource: SqlParameterSource): Int

executeAndReturnKey

open fun executeAndReturnKey(args: MutableMap<String, *>): Number
open fun executeAndReturnKey(parameterSource: SqlParameterSource): Number

executeAndReturnKeyHolder

open fun executeAndReturnKeyHolder(args: MutableMap<String, *>): KeyHolder
open fun executeAndReturnKeyHolder(parameterSource: SqlParameterSource): KeyHolder

executeBatch

open fun executeBatch(vararg batch: MutableMap<String, *>): IntArray
open fun executeBatch(vararg batch: SqlParameterSource): IntArray

includeSynonymsForTableColumnMetaData

open fun includeSynonymsForTableColumnMetaData(): SimpleJdbcInsertOperations

usingColumns

open fun usingColumns(vararg columnNames: String): SimpleJdbcInsert

usingGeneratedKeyColumns

open fun usingGeneratedKeyColumns(vararg columnNames: String): SimpleJdbcInsert

withCatalogName

open fun withCatalogName(catalogName: String): SimpleJdbcInsert

withSchemaName

open fun withSchemaName(schemaName: String): SimpleJdbcInsert

withTableName

open fun withTableName(tableName: String): SimpleJdbcInsert

withoutTableColumnMetaDataAccess

open fun withoutTableColumnMetaDataAccess(): SimpleJdbcInsertOperations