public abstract class

AbstractJdbcInsert

extends Object
java.lang.Object
   ↳ org.springframework.jdbc.core.simple.AbstractJdbcInsert
Known Direct Subclasses

Class Overview

Abstract class to provide base functionality for easy inserts based on configuration options and database metadata. This class provides the base SPI for SimpleJdbcInsert.

Summary

Fields
protected final Log logger Logger available to subclasses
Protected Constructors
AbstractJdbcInsert(DataSource dataSource)
Constructor for sublasses to delegate to for setting the DataSource.
AbstractJdbcInsert(JdbcTemplate jdbcTemplate)
Constructor for sublasses to delegate to for setting the JdbcTemplate.
Public Methods
synchronized final void compile()
Compile this JdbcInsert using provided parameters and meta data plus other settings.
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 java.sql.Types to be used for insert
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"?
void setAccessTableColumnMetaData(boolean accessTableColumnMetaData)
Specify whether the parameter metadata 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 setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
Set the NativeJdbcExtractor to use to retrieve the native connection if necessary
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 Methods
void checkCompiled()
Check whether this operation has been compiled already; lazily compile it if not already compiled.
void checkIfConfigurationModificationIsAllowed()
Method to check whether we are allowd to make any configuration changes at this time.
void compileInternal()
Method to perform the actual compilation.
int doExecute(SqlParameterSource parameterSource)
Method that provides execution of the insert using the passed in SqlParameterSource
int doExecute(Map<StringObject> args)
Method that provides execution of the insert using the passed in Map of parameters
Number doExecuteAndReturnKey(SqlParameterSource parameterSource)
Method that provides execution of the insert using the passed in SqlParameterSource and returning a generated key
Number doExecuteAndReturnKey(Map<StringObject> args)
Method that provides execution of the insert using the passed in Map of parameters and returning a generated key
KeyHolder doExecuteAndReturnKeyHolder(SqlParameterSource parameterSource)
Method that provides execution of the insert using the passed in SqlParameterSource and returning all generated keys
KeyHolder doExecuteAndReturnKeyHolder(Map<StringObject> args)
Method that provides execution of the insert using the passed in Map of parameters and returning all generated keys
int[] doExecuteBatch(SqlParameterSource[] batch)
Method that provides execution of a batch insert using the passed in array of SqlParameterSource
int[] doExecuteBatch(Map[]<StringObject> batch)
Method that provides execution of a batch insert using the passed in Maps of parameters
JdbcTemplate getJdbcTemplate()
Get the JdbcTemplate that is configured to be used
List<Object> matchInParameterValuesWithInsertColumns(Map<StringObject> args)
Match the provided in parameter values with regitered parameters and parameters defined via metedata processing.
List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)
Match the provided in parameter values with regitered parameters and parameters defined via metedata processing.
void onCompileInternal()
Hook method that subclasses may override to react to compilation.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected final Log logger

Logger available to subclasses

Protected Constructors

protected AbstractJdbcInsert (DataSource dataSource)

Constructor for sublasses to delegate to for setting the DataSource.

protected AbstractJdbcInsert (JdbcTemplate jdbcTemplate)

Constructor for sublasses to delegate to for setting the JdbcTemplate.

Public Methods

public final synchronized void compile ()

Compile this JdbcInsert using provided parameters and meta data plus other settings. This finalizes the configuration for this object and subsequent attempts to compile are ignored. This will be implicitly called the first time an un-compiled insert is executed.

Throws
InvalidDataAccessApiUsageException if the object hasn't been correctly initialized, for example if no DataSource has been provided

public String getCatalogName ()

Get the name of the catalog for this insert

public List<String> getColumnNames ()

Get the names of the columns used

public String[] getGeneratedKeyNames ()

Get the names of any generated keys

public String getInsertString ()

Get the insert string to be used

public int[] getInsertTypes ()

Get the array of java.sql.Types to be used for insert

public String getSchemaName ()

Get the name of the schema for this insert

public String getTableName ()

Get the name of the table for this insert

public boolean isCompiled ()

Is this operation "compiled"?

Returns
  • whether this operation is compiled, and ready to use.

public void setAccessTableColumnMetaData (boolean accessTableColumnMetaData)

Specify whether the parameter metadata for the call should be used. The default is true.

public void setCatalogName (String catalogName)

Set the name of the catalog for this insert

public void setColumnNames (List<String> columnNames)

Set the names of the columns to be used

public void setGeneratedKeyName (String generatedKeyName)

Specify the name of a single generated key column

public void setGeneratedKeyNames (String[] generatedKeyNames)

Set the names of any generated keys

public void setNativeJdbcExtractor (NativeJdbcExtractor nativeJdbcExtractor)

Set the NativeJdbcExtractor to use to retrieve the native connection if necessary

public void setOverrideIncludeSynonymsDefault (boolean override)

Specify whether the default for including synonyms should be changed. The default is false.

public void setSchemaName (String schemaName)

Set the name of the schema for this insert

public void setTableName (String tableName)

Set the name of the table for this insert

Protected Methods

protected void checkCompiled ()

Check whether this operation has been compiled already; lazily compile it if not already compiled.

Automatically called by validateParameters.

protected void checkIfConfigurationModificationIsAllowed ()

Method to check whether we are allowd to make any configuration changes at this time. If the class has been compiled, then no further changes to the configuration are allowed.

protected void compileInternal ()

Method to perform the actual compilation. Subclasses can override this template method to perform their own compilation. Invoked after this base class's compilation is complete.

protected int doExecute (SqlParameterSource parameterSource)

Method that provides execution of the insert using the passed in SqlParameterSource

Parameters
parameterSource parameter names and values to be used in insert
Returns
  • number of rows affected

protected int doExecute (Map<StringObject> args)

Method that provides execution of the insert using the passed in Map of parameters

Parameters
args Map with parameter names and values to be used in insert
Returns
  • number of rows affected

protected Number doExecuteAndReturnKey (SqlParameterSource parameterSource)

Method that provides execution of the insert using the passed in SqlParameterSource and returning a generated key

Parameters
parameterSource parameter names and values to be used in insert
Returns
  • the key generated by the insert

protected Number doExecuteAndReturnKey (Map<StringObject> args)

Method that provides execution of the insert using the passed in Map of parameters and returning a generated key

Parameters
args Map with parameter names and values to be used in insert
Returns
  • the key generated by the insert

protected KeyHolder doExecuteAndReturnKeyHolder (SqlParameterSource parameterSource)

Method that provides execution of the insert using the passed in SqlParameterSource and returning all generated keys

Parameters
parameterSource parameter names and values to be used in insert
Returns
  • the KeyHolder containing keys generated by the insert

protected KeyHolder doExecuteAndReturnKeyHolder (Map<StringObject> args)

Method that provides execution of the insert using the passed in Map of parameters and returning all generated keys

Parameters
args Map with parameter names and values to be used in insert
Returns
  • the KeyHolder containing keys generated by the insert

protected int[] doExecuteBatch (SqlParameterSource[] batch)

Method that provides execution of a batch insert using the passed in array of SqlParameterSource

Parameters
batch array of SqlParameterSource with parameter names and values to be used in insert
Returns
  • array of number of rows affected

protected int[] doExecuteBatch (Map[]<StringObject> batch)

Method that provides execution of a batch insert using the passed in Maps of parameters

Parameters
batch array of Maps with parameter names and values to be used in batch insert
Returns
  • array of number of rows affected

protected JdbcTemplate getJdbcTemplate ()

Get the JdbcTemplate that is configured to be used

protected List<Object> matchInParameterValuesWithInsertColumns (Map<StringObject> args)

Match the provided in parameter values with regitered parameters and parameters defined via metedata processing.

Parameters
args the parameter values provided in a Map
Returns
  • Map with parameter names and values

protected List<Object> matchInParameterValuesWithInsertColumns (SqlParameterSource parameterSource)

Match the provided in parameter values with regitered parameters and parameters defined via metedata processing.

Parameters
parameterSource the parameter vakues provided as a SqlParameterSource
Returns
  • Map with parameter names and values

protected void onCompileInternal ()

Hook method that subclasses may override to react to compilation. This implementation does nothing.