Top Description Methods
org.springframework.jdbc.core.simple

public Interface SimpleJdbcInsertOperations

Known Direct Implementers
org.springframework.jdbc.core.simple.SimpleJdbcInsert
Imports
java.util.Map, org.springframework.jdbc.core.namedparam.SqlParameterSource, org.springframework.jdbc.support.KeyHolder

Interface specifying the API for a Simple JDBC Insert implemented by SimpleJdbcInsert.

This interface is not often used directly, but provides the option to enhance testability, as it can easily be mocked or stubbed.

Authors
Thomas Risberg, Sam Brannen
Since
2.5

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of rows affected as returned by the JDBC driver
execute
(Map<String, ?>
a Map containing column names and corresponding value
args
)

Execute the insert using the values passed in.

public int

Returns:

the number of rows affected as returned by the JDBC driver
execute
(SqlParameterSource
the SqlParameterSource containing values to use for insert
parameterSource
)

Execute the insert using the values passed in.

public Number

Returns:

the generated key value
executeAndReturnKey
(Map<String, ?>
a Map containing column names and corresponding value
args
)

Execute the insert using the values passed in and return the generated key.

public Number

Returns:

the generated key value.
executeAndReturnKey
(SqlParameterSource
the SqlParameterSource containing values to use for insert
parameterSource
)

Execute the insert using the values passed in and return the generated key.

public KeyHolder

Returns:

the KeyHolder containing all generated keys
executeAndReturnKeyHolder
(Map<String, ?>
a Map containing column names and corresponding value
args
)

Execute the insert using the values passed in and return the generated keys.

public KeyHolder

Returns:

the KeyHolder containing all generated keys
executeAndReturnKeyHolder
(SqlParameterSource
the SqlParameterSource containing values to use for insert
parameterSource
)

Execute the insert using the values passed in and return the generated keys.

public int[]

Returns:

the array of number of rows affected as returned by the JDBC driver
executeBatch
(Map<String, ?>...
an array of Maps containing a batch of column names and corresponding value
batch
)

Execute a batch insert using the batch of values passed in.

public int[]

Returns:

the array of number of rows affected as returned by the JDBC driver
executeBatch
(SqlParameterSource...
an array of SqlParameterSource containing values for the batch
batch
)

Execute a batch insert using the batch of values passed in.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
includeSynonymsForTableColumnMetaData
()

Include synonyms for the column meta-data lookups via JDBC.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
usingColumns
(String...
one or more column names
columnNames
)

Specify the column names that the insert statement should be limited to use.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
usingGeneratedKeyColumns
(String...
one or more column names
columnNames
)

Specify the names of any columns that have auto-generated keys.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
usingQuotedIdentifiers
()

Specify that SQL identifiers should be quoted.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
withCatalogName
(String
the name of the catalog
catalogName
)

Specify the catalog name, if any, to be used for the insert.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
withoutTableColumnMetaDataAccess
()

Turn off any processing of column meta-data information obtained via JDBC.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
withSchemaName
(String
the name of the schema
schemaName
)

Specify the schema name, if any, to be used for the insert.

public SimpleJdbcInsertOperations

Returns:

this SimpleJdbcInsert (for method chaining)
withTableName
(String
the name of the stored table
tableName
)

Specify the table name to be used for the insert.

Method Detail

executeback to summary
public int execute(Map<String, ?> args)

Execute the insert using the values passed in.

Parameters
args:Map<String, ?>

a Map containing column names and corresponding value

Returns:int

the number of rows affected as returned by the JDBC driver

executeback to summary
public int execute(SqlParameterSource parameterSource)

Execute the insert using the values passed in.

Parameters
parameterSource:SqlParameterSource

the SqlParameterSource containing values to use for insert

Returns:int

the number of rows affected as returned by the JDBC driver

executeAndReturnKeyback to summary
public Number executeAndReturnKey(Map<String, ?> args)

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:Map<String, ?>

a Map containing column names and corresponding value

Returns:Number

the generated key value

executeAndReturnKeyback to summary
public Number executeAndReturnKey(SqlParameterSource parameterSource)

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:SqlParameterSource

the SqlParameterSource containing values to use for insert

Returns:Number

the generated key value.

executeAndReturnKeyHolderback to summary
public KeyHolder executeAndReturnKeyHolder(Map<String, ?> args)

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:Map<String, ?>

a Map containing column names and corresponding value

Returns:KeyHolder

the KeyHolder containing all generated keys

executeAndReturnKeyHolderback to summary
public KeyHolder executeAndReturnKeyHolder(SqlParameterSource parameterSource)

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:SqlParameterSource

the SqlParameterSource containing values to use for insert

Returns:KeyHolder

the KeyHolder containing all generated keys

executeBatchback to summary
public int[] executeBatch(Map<String, ?>... batch)

Execute a batch insert using the batch of values passed in.

Parameters
batch:Map<String, ?>[]

an array of Maps containing a batch of column names and corresponding value

Returns:int[]

the array of number of rows affected as returned by the JDBC driver

Annotations
@SuppressWarnings:unchecked
executeBatchback to summary
public int[] executeBatch(SqlParameterSource... batch)

Execute a batch insert using the batch of values passed in.

Parameters
batch:SqlParameterSource[]

an array of SqlParameterSource containing values for the batch

Returns:int[]

the array of number of rows affected as returned by the JDBC driver

includeSynonymsForTableColumnMetaDataback to summary
public 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:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

usingColumnsback to summary
public SimpleJdbcInsertOperations usingColumns(String... columnNames)

Specify the column names that the insert statement should be limited to use.

Parameters
columnNames:String[]

one or more column names

Returns:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

usingGeneratedKeyColumnsback to summary
public SimpleJdbcInsertOperations usingGeneratedKeyColumns(String... columnNames)

Specify the names of any columns that have auto-generated keys.

Parameters
columnNames:String[]

one or more column names

Returns:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

usingQuotedIdentifiersback to summary
public 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:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

Since
6.1
See Also
withSchemaName(String), withTableName(String), usingColumns(String...), java.sql.DatabaseMetaData#getIdentifierQuoteString(), java.sql.DatabaseMetaData#storesMixedCaseIdentifiers(), java.sql.DatabaseMetaData#storesMixedCaseQuotedIdentifiers(), java.sql.DatabaseMetaData#storesUpperCaseIdentifiers(), java.sql.DatabaseMetaData#storesUpperCaseQuotedIdentifiers(), java.sql.DatabaseMetaData#storesLowerCaseIdentifiers(), java.sql.DatabaseMetaData#storesLowerCaseQuotedIdentifiers()
withCatalogNameback to summary
public SimpleJdbcInsertOperations withCatalogName(String catalogName)

Specify the catalog name, if any, to be used for the insert.

Parameters
catalogName:String

the name of the catalog

Returns:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

withoutTableColumnMetaDataAccessback to summary
public SimpleJdbcInsertOperations withoutTableColumnMetaDataAccess()

Turn off any processing of column meta-data information obtained via JDBC.

Returns:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

withSchemaNameback to summary
public SimpleJdbcInsertOperations withSchemaName(String schemaName)

Specify the schema name, if any, to be used for the insert.

Parameters
schemaName:String

the name of the schema

Returns:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)

withTableNameback to summary
public SimpleJdbcInsertOperations withTableName(String tableName)

Specify the table name to be used for the insert.

Parameters
tableName:String

the name of the stored table

Returns:SimpleJdbcInsertOperations

this SimpleJdbcInsert (for method chaining)