public class SimpleJdbcInsert extends AbstractJdbcInsert implements SimpleJdbcInsertOperations
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 chain multiple ones together in a "fluent" interface style.
DatabaseMetaData,
JdbcTemplatelogger| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
int |
execute(Map<String,Object> args)
Execute the insert using the values passed in.
|
int |
execute(SqlParameterSource parameterSource)
Execute the insert using the values passed in.
|
Number |
executeAndReturnKey(Map<String,Object> args)
Execute the insert using the values passed in and return the generated key.
|
Number |
executeAndReturnKey(SqlParameterSource parameterSource)
Execute the insert using the values passed in and return the generated key.
|
KeyHolder |
executeAndReturnKeyHolder(Map<String,Object> args)
Execute the insert using the values passed in and return the generated keys.
|
KeyHolder |
executeAndReturnKeyHolder(SqlParameterSource parameterSource)
Execute the insert using the values passed in and return the generated keys.
|
int[] |
executeBatch(Map<String,Object>[] 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.
|
SimpleJdbcInsertOperations |
includeSynonymsForTableColumnMetaData()
Include synonyms for the column meta data lookups via JDBC.
|
SimpleJdbcInsertOperations |
useNativeJdbcExtractorForMetaData(NativeJdbcExtractor nativeJdbcExtractor)
Use a the provided NativeJdbcExtractor during the column meta data
lookups via JDBC.
|
SimpleJdbcInsert |
usingColumns(String... columnNames)
Specify the column names that the insert statement should be limited to use.
|
SimpleJdbcInsert |
usingGeneratedKeyColumns(String... columnNames)
Specify the name sof any columns that have auto generated keys.
|
SimpleJdbcInsert |
withCatalogName(String catalogName)
Specify the catalog name, if any, to be used for the insert.
|
SimpleJdbcInsertOperations |
withoutTableColumnMetaDataAccess()
Turn off any processing of column meta data information obtained via JDBC.
|
SimpleJdbcInsert |
withSchemaName(String schemaName)
Specify the schema name, if any, to be used for the insert.
|
SimpleJdbcInsert |
withTableName(String tableName)
Specify the table name to be used for the insert.
|
checkCompiled, checkIfConfigurationModificationIsAllowed, compile, compileInternal, doExecute, doExecute, doExecuteAndReturnKey, doExecuteAndReturnKey, doExecuteAndReturnKeyHolder, doExecuteAndReturnKeyHolder, doExecuteBatch, doExecuteBatch, getCatalogName, getColumnNames, getGeneratedKeyNames, getInsertString, getInsertTypes, getJdbcTemplate, getSchemaName, getTableName, isCompiled, matchInParameterValuesWithInsertColumns, matchInParameterValuesWithInsertColumns, onCompileInternal, setAccessTableColumnMetaData, setCatalogName, setColumnNames, setGeneratedKeyName, setGeneratedKeyNames, setNativeJdbcExtractor, setOverrideIncludeSynonymsDefault, setSchemaName, setTableNamepublic SimpleJdbcInsert(DataSource dataSource)
dataSource - the DataSource to useJdbcAccessor.setDataSource(javax.sql.DataSource)public SimpleJdbcInsert(JdbcTemplate jdbcTemplate)
jdbcTemplate - the JdbcTemplate to useJdbcAccessor.setDataSource(javax.sql.DataSource)public SimpleJdbcInsert withTableName(String tableName)
SimpleJdbcInsertOperationswithTableName in interface SimpleJdbcInsertOperationstableName - the name of the stored tablepublic SimpleJdbcInsert withSchemaName(String schemaName)
SimpleJdbcInsertOperationswithSchemaName in interface SimpleJdbcInsertOperationsschemaName - the name of the schemapublic SimpleJdbcInsert withCatalogName(String catalogName)
SimpleJdbcInsertOperationswithCatalogName in interface SimpleJdbcInsertOperationscatalogName - the name of the catalogpublic SimpleJdbcInsert usingColumns(String... columnNames)
SimpleJdbcInsertOperationsusingColumns in interface SimpleJdbcInsertOperationscolumnNames - one or more column namespublic SimpleJdbcInsert usingGeneratedKeyColumns(String... columnNames)
SimpleJdbcInsertOperationsusingGeneratedKeyColumns in interface SimpleJdbcInsertOperationscolumnNames - one or more column namespublic SimpleJdbcInsertOperations withoutTableColumnMetaDataAccess()
SimpleJdbcInsertOperationswithoutTableColumnMetaDataAccess in interface SimpleJdbcInsertOperationspublic SimpleJdbcInsertOperations includeSynonymsForTableColumnMetaData()
SimpleJdbcInsertOperationsincludeSynonymsForTableColumnMetaData in interface SimpleJdbcInsertOperationspublic SimpleJdbcInsertOperations useNativeJdbcExtractorForMetaData(NativeJdbcExtractor nativeJdbcExtractor)
SimpleJdbcInsertOperationsuseNativeJdbcExtractorForMetaData in interface SimpleJdbcInsertOperationspublic int execute(Map<String,Object> args)
SimpleJdbcInsertOperationsexecute in interface SimpleJdbcInsertOperationsargs - Map containing column names and corresponding valuepublic int execute(SqlParameterSource parameterSource)
SimpleJdbcInsertOperationsexecute in interface SimpleJdbcInsertOperationsparameterSource - SqlParameterSource containing values to use for insertpublic Number executeAndReturnKey(Map<String,Object> args)
SimpleJdbcInsertOperationsexecuteAndReturnKey in interface SimpleJdbcInsertOperationsargs - Map containing column names and corresponding valuepublic Number executeAndReturnKey(SqlParameterSource parameterSource)
SimpleJdbcInsertOperationsexecuteAndReturnKey in interface SimpleJdbcInsertOperationsparameterSource - SqlParameterSource containing values to use for insertpublic KeyHolder executeAndReturnKeyHolder(Map<String,Object> args)
SimpleJdbcInsertOperationsexecuteAndReturnKeyHolder in interface SimpleJdbcInsertOperationsargs - Map containing column names and corresponding valuepublic KeyHolder executeAndReturnKeyHolder(SqlParameterSource parameterSource)
SimpleJdbcInsertOperationsexecuteAndReturnKeyHolder in interface SimpleJdbcInsertOperationsparameterSource - SqlParameterSource containing values to use for insertpublic int[] executeBatch(Map<String,Object>[] batch)
SimpleJdbcInsertOperationsexecuteBatch in interface SimpleJdbcInsertOperationsbatch - an array of Maps containing a batch of column names and corresponding valuepublic int[] executeBatch(SqlParameterSource[] batch)
SimpleJdbcInsertOperationsexecuteBatch in interface SimpleJdbcInsertOperationsbatch - an array of SqlParameterSource containing values for the batch