Interface SimpleJdbcInsertOperations
- All Known Implementing Classes:
SimpleJdbcInsert
SimpleJdbcInsert
.
This interface is not often used directly, but provides the option to enhance testability, as it can easily be mocked or stubbed.
- Since:
- 2.5
- Author:
- Thomas Risberg, Sam Brannen
-
Method Summary
Modifier and TypeMethodDescriptionint
Execute the insert using the values passed in.int
execute
(SqlParameterSource parameterSource) Execute the insert using the values passed in.executeAndReturnKey
(Map<String, ?> args) Execute the insert using the values passed in and return the generated key.executeAndReturnKey
(SqlParameterSource parameterSource) Execute the insert using the values passed in and return the generated key.executeAndReturnKeyHolder
(Map<String, ?> args) Execute the insert using the values passed in and return the generated keys.executeAndReturnKeyHolder
(SqlParameterSource parameterSource) Execute the insert using the values passed in and return the generated keys.int[]
executeBatch
(Map<String, ?>... batch) Execute a batch insert using the batch of values passed in.int[]
executeBatch
(SqlParameterSource... batch) Execute a batch insert using the batch of values passed in.Include synonyms for the column meta-data lookups via JDBC.usingColumns
(String... columnNames) Specify the column names that the insert statement should be limited to use.usingGeneratedKeyColumns
(String... columnNames) Specify the names of any columns that have auto-generated keys.Specify that SQL identifiers should be quoted.withCatalogName
(String catalogName) Specify the catalog name, if any, to be used for the insert.Turn off any processing of column meta-data information obtained via JDBC.withSchemaName
(String schemaName) Specify the schema name, if any, to be used for the insert.withTableName
(String tableName) Specify the table name to be used for the insert.
-
Method Details
-
withTableName
Specify the table name to be used for the insert.- Parameters:
tableName
- the name of the stored table- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
withSchemaName
Specify the schema name, if any, to be used for the insert.- Parameters:
schemaName
- the name of the schema- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
withCatalogName
Specify the catalog name, if any, to be used for the insert.- Parameters:
catalogName
- the name of the catalog- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
usingColumns
Specify the column names that the insert statement should be limited to use.- Parameters:
columnNames
- one or more column names- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
usingGeneratedKeyColumns
Specify the names of any columns that have auto-generated keys.- Parameters:
columnNames
- one or more column names- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
usingQuotedIdentifiers
SimpleJdbcInsertOperations usingQuotedIdentifiers()Specify that SQL identifiers should be quoted.If this method is invoked, the identifier quote string for the underlying database will be used to quote SQL identifiers in generated SQL statements. In this context, SQL identifiers refer to schema, table, and column names.
When identifiers are quoted, explicit column names must be supplied via
usingColumns(String...)
. Furthermore, all identifiers for the schema name, table name, and column names must match the corresponding identifiers in the database's metadata regarding casing (mixed case, uppercase, or lowercase).- Returns:
- this
SimpleJdbcInsert
(for method chaining) - Since:
- 6.1
- See Also:
-
withSchemaName(String)
withTableName(String)
usingColumns(String...)
DatabaseMetaData.getIdentifierQuoteString()
DatabaseMetaData.storesMixedCaseIdentifiers()
DatabaseMetaData.storesMixedCaseQuotedIdentifiers()
DatabaseMetaData.storesUpperCaseIdentifiers()
DatabaseMetaData.storesUpperCaseQuotedIdentifiers()
DatabaseMetaData.storesLowerCaseIdentifiers()
DatabaseMetaData.storesLowerCaseQuotedIdentifiers()
-
withoutTableColumnMetaDataAccess
SimpleJdbcInsertOperations withoutTableColumnMetaDataAccess()Turn off any processing of column meta-data information obtained via JDBC.- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
includeSynonymsForTableColumnMetaData
SimpleJdbcInsertOperations includeSynonymsForTableColumnMetaData()Include synonyms for the column meta-data lookups via JDBC.Note: This is only necessary to include for Oracle since other databases supporting synonyms seem to include the synonyms automatically.
- Returns:
- this
SimpleJdbcInsert
(for method chaining)
-
execute
Execute the insert using the values passed in.- Parameters:
args
- a Map containing column names and corresponding value- Returns:
- the number of rows affected as returned by the JDBC driver
-
execute
Execute the insert using the values passed in.- Parameters:
parameterSource
- the SqlParameterSource containing values to use for insert- Returns:
- the number of rows affected as returned by the JDBC driver
-
executeAndReturnKey
Execute the insert using the values passed in and return the generated key.This requires that the name of the columns with auto generated keys have been specified. This method will always return a KeyHolder but the caller must verify that it actually contains the generated keys.
- Parameters:
args
- a Map containing column names and corresponding value- Returns:
- the generated key value
-
executeAndReturnKey
Execute the insert using the values passed in and return the generated key.This requires that the name of the columns with auto generated keys have been specified. This method will always return a KeyHolder but the caller must verify that it actually contains the generated keys.
- Parameters:
parameterSource
- the SqlParameterSource containing values to use for insert- Returns:
- the generated key value.
-
executeAndReturnKeyHolder
Execute the insert using the values passed in and return the generated keys.This requires that the name of the columns with auto generated keys have been specified. This method will always return a KeyHolder but the caller must verify that it actually contains the generated keys.
- Parameters:
args
- a Map containing column names and corresponding value- Returns:
- the KeyHolder containing all generated keys
-
executeAndReturnKeyHolder
Execute the insert using the values passed in and return the generated keys.This requires that the name of the columns with auto generated keys have been specified. This method will always return a KeyHolder but the caller must verify that it actually contains the generated keys.
- Parameters:
parameterSource
- the SqlParameterSource containing values to use for insert- Returns:
- the KeyHolder containing all generated keys
-
executeBatch
Execute a batch insert using the batch of values passed in.- Parameters:
batch
- an array of Maps containing a batch of column names and corresponding value- Returns:
- the array of number of rows affected as returned by the JDBC driver
-
executeBatch
Execute a batch insert using the batch of values passed in.- Parameters:
batch
- an array of SqlParameterSource containing values for the batch- Returns:
- the array of number of rows affected as returned by the JDBC driver
-