public abstract class AbstractJdbcInsert extends Object
This class provides the base SPI for SimpleJdbcInsert
.
Modifier and Type | Field and Description |
---|---|
protected Log |
logger
Logger available to subclasses.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractJdbcInsert(DataSource dataSource)
Constructor to be used when initializing using a
DataSource . |
protected |
AbstractJdbcInsert(JdbcTemplate jdbcTemplate)
Constructor to be used when initializing using a
JdbcTemplate . |
Modifier and Type | Method and Description |
---|---|
protected void |
checkCompiled()
Check whether this operation has been compiled already;
lazily compile it if not already compiled.
|
protected void |
checkIfConfigurationModificationIsAllowed()
Method to check whether we are allowed to make any configuration changes at this time.
|
void |
compile()
Compile this JdbcInsert using provided parameters and meta-data plus other settings.
|
protected void |
compileInternal()
Delegate method to perform the actual compilation.
|
protected int |
doExecute(Map<String,?> args)
Delegate method that executes the insert using the passed-in Map of parameters.
|
protected int |
doExecute(SqlParameterSource parameterSource)
Delegate method that executes the insert using the passed-in
SqlParameterSource . |
protected Number |
doExecuteAndReturnKey(Map<String,?> args)
Method that provides execution of the insert using the passed-in
Map of parameters and returning a generated key.
|
protected Number |
doExecuteAndReturnKey(SqlParameterSource parameterSource)
Method that provides execution of the insert using the passed-in
SqlParameterSource and returning a generated key. |
protected KeyHolder |
doExecuteAndReturnKeyHolder(Map<String,?> args)
Method that provides execution of the insert using the passed-in
Map of parameters and returning all generated keys.
|
protected KeyHolder |
doExecuteAndReturnKeyHolder(SqlParameterSource parameterSource)
Method that provides execution of the insert using the passed-in
SqlParameterSource and returning all generated keys. |
protected int[] |
doExecuteBatch(Map<String,?>... batch)
Delegate method that executes a batch insert using the passed-in Maps of parameters.
|
protected int[] |
doExecuteBatch(SqlParameterSource... batch)
Delegate method that executes a batch insert using the passed-in
SqlParameterSources . |
String |
getCatalogName()
Get the name of the catalog for this insert.
|
List<String> |
getColumnNames()
Get the names of the columns used.
|
String[] |
getGeneratedKeyNames()
Get the names of any generated keys.
|
String |
getInsertString()
Get the insert string to be used.
|
int[] |
getInsertTypes()
Get the array of
Types to be used for insert. |
JdbcTemplate |
getJdbcTemplate()
Get the configured
JdbcTemplate . |
String |
getSchemaName()
Get the name of the schema for this insert.
|
String |
getTableName()
Get the name of the table for this insert.
|
boolean |
isCompiled()
Is this operation "compiled"?
|
protected List<Object> |
matchInParameterValuesWithInsertColumns(Map<String,?> args)
Match the provided in parameter values with registered parameters and parameters
defined via meta-data processing.
|
protected List<Object> |
matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)
Match the provided in parameter values with registered parameters and parameters
defined via meta-data processing.
|
protected void |
onCompileInternal()
Hook method that subclasses may override to react to compilation.
|
void |
setAccessTableColumnMetaData(boolean accessTableColumnMetaData)
Specify whether the parameter meta-data for the call should be used.
|
void |
setCatalogName(String catalogName)
Set the name of the catalog for this insert.
|
void |
setColumnNames(List<String> columnNames)
Set the names of the columns to be used.
|
void |
setGeneratedKeyName(String generatedKeyName)
Specify the name of a single generated key column.
|
void |
setGeneratedKeyNames(String... generatedKeyNames)
Set the names of any generated keys.
|
void |
setOverrideIncludeSynonymsDefault(boolean override)
Specify whether the default for including synonyms should be changed.
|
void |
setSchemaName(String schemaName)
Set the name of the schema for this insert.
|
void |
setTableName(String tableName)
Set the name of the table for this insert.
|
protected final Log logger
protected AbstractJdbcInsert(DataSource dataSource)
DataSource
.dataSource
- the DataSource to be usedprotected AbstractJdbcInsert(JdbcTemplate jdbcTemplate)
JdbcTemplate
.jdbcTemplate
- the JdbcTemplate to usepublic JdbcTemplate getJdbcTemplate()
JdbcTemplate
.public void setTableName(@Nullable String tableName)
public void setSchemaName(@Nullable String schemaName)
public void setCatalogName(@Nullable String catalogName)
@Nullable public String getCatalogName()
public void setColumnNames(List<String> columnNames)
public void setGeneratedKeyName(String generatedKeyName)
public void setGeneratedKeyNames(String... generatedKeyNames)
public String[] getGeneratedKeyNames()
public void setAccessTableColumnMetaData(boolean accessTableColumnMetaData)
true
.public void setOverrideIncludeSynonymsDefault(boolean override)
false
.public String getInsertString()
public int[] getInsertTypes()
Types
to be used for insert.public final void compile() throws InvalidDataAccessApiUsageException
InvalidDataAccessApiUsageException
- if the object hasn't been correctly initialized,
for example if no DataSource has been providedprotected void compileInternal()
Subclasses can override this template method to perform their own compilation. Invoked after this base class's compilation is complete.
protected void onCompileInternal()
This implementation is empty.
public boolean isCompiled()
protected void checkCompiled()
Automatically called by all doExecute*(...)
methods.
protected void checkIfConfigurationModificationIsAllowed()
If the class has been compiled, then no further changes to the configuration are allowed.
protected int doExecute(Map<String,?> args)
args
- a Map with parameter names and values to be used in insertprotected int doExecute(SqlParameterSource parameterSource)
SqlParameterSource
.parameterSource
- parameter names and values to be used in insertprotected Number doExecuteAndReturnKey(Map<String,?> args)
args
- a Map with parameter names and values to be used in insertprotected Number doExecuteAndReturnKey(SqlParameterSource parameterSource)
SqlParameterSource
and returning a generated key.parameterSource
- parameter names and values to be used in insertprotected KeyHolder doExecuteAndReturnKeyHolder(Map<String,?> args)
args
- a Map with parameter names and values to be used in insertprotected KeyHolder doExecuteAndReturnKeyHolder(SqlParameterSource parameterSource)
SqlParameterSource
and returning all generated keys.parameterSource
- parameter names and values to be used in insertprotected int[] doExecuteBatch(Map<String,?>... batch)
batch
- array of Maps with parameter names and values to be used in batch insertprotected int[] doExecuteBatch(SqlParameterSource... batch)
SqlParameterSources
.batch
- array of SqlParameterSource with parameter names and values to be used in insertprotected List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)
parameterSource
- the parameter values provided as a SqlParameterSource
protected List<Object> matchInParameterValuesWithInsertColumns(Map<String,?> args)
args
- the parameter values provided in a Map