java.lang.Object | ||
↳ | org.springframework.jdbc.core.simple.AbstractJdbcInsert | |
↳ | org.springframework.jdbc.core.simple.SimpleJdbcInsert |
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 JBDC 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
JdbcTemplate
.
Many of the configuration methods return the current instance of the SimpleJdbcInsert to provide the ability to string multiple ones together in a "fluid" interface style.
JdbcTemplate
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jdbc.core.simple.AbstractJdbcInsert
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor that takes one parameter with the JDBC DataSource to use when creating the
JdbcTemplate.
| |||||||||||
Alternative Constructor that takes one parameter with the JdbcTemplate to be used.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Execute the insert using the values passed in.
| |||||||||||
Execute the insert using the values passed in.
| |||||||||||
Execute the insert using the values passed in and return the generated key.
| |||||||||||
Execute the insert using the values passed in and return the generated key.
| |||||||||||
Execute the insert using the values passed in and return the generated keys.
| |||||||||||
Execute the insert using the values passed in and return the generated keys.
| |||||||||||
Execute a batch insert using the batch of values passed in.
| |||||||||||
Execute a batch insert using the batch of values passed in.
| |||||||||||
Include synonyms for the column meta data lookups via JDBC.
| |||||||||||
Use a the provided NativeJdbcExtractor during the column meta data
lookups via JDBC.
| |||||||||||
Specify the column names that the insert statement should be limited to use.
| |||||||||||
Specify the name sof any columns that have auto generated keys.
| |||||||||||
Specify the catalog name, if any, to be used for the insert.
| |||||||||||
Specify the shema name, if any, to be used for the insert.
| |||||||||||
Specify the table name to be used for the insert.
| |||||||||||
Turn off any processing of column meta data information obtained via JDBC.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jdbc.core.simple.AbstractJdbcInsert
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.jdbc.core.simple.SimpleJdbcInsertOperations
|
Constructor that takes one parameter with the JDBC DataSource to use when creating the JdbcTemplate.
dataSource | the DataSource to use |
---|
Alternative Constructor that takes one parameter with the JdbcTemplate to be used.
jdbcTemplate | the JdbcTemplate to use |
---|
Execute the insert using the values passed in.
args | Map containing column names and corresponding value |
---|
Execute the insert using the values passed in.
parameterSource | SqlParameterSource containing values to use for insert |
---|
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 key or throw an exception if a key was not returned.
parameterSource | SqlParameterSource containing values to use for insert |
---|
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 key or throw an exception if a key was not returned.
args | Map containing column names and corresponding value |
---|
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.
parameterSource | SqlParameterSource containing values to use for insert |
---|
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.
args | Map containing column names and corresponding value |
---|
Execute a batch insert using the batch of values passed in.
batch | an array of SqlParameterSource containing values for the batch |
---|
Execute a batch insert using the batch of values passed in.
batch | an array of Maps containing a batch of column names and corresponding value |
---|
Include synonyms for the column meta data lookups via JDBC. Note: this is only necessary to include for Oracle since other databases supporting synonyms seems to include the synonyms automatically.
Use a the provided NativeJdbcExtractor during the column meta data lookups via JDBC. Note: this is only necessary to include when running with a connection pool that wraps the meta data connection and when using a database like Oracle where it is necessary to access the native connection to include synonyms.
Specify the column names that the insert statement should be limited to use.
columnNames | one or more column names |
---|
Specify the name sof any columns that have auto generated keys.
columnNames | one or more column names |
---|
Specify the catalog name, if any, to be used for the insert.
catalogName | the name of the catalog |
---|
Specify the shema name, if any, to be used for the insert.
schemaName | the name of the schema |
---|
Specify the table name to be used for the insert.
tableName | the name of the stored table |
---|
Turn off any processing of column meta data information obtained via JDBC.