This class and subclasses throw runtime exceptions, defined in the
org.springframework.dao package (and as thrown by the
org.springframework.jdbc.core package, which the classes
in this package use under the hood to perform raw JDBC operations).
Subclasses should set SQL and add parameters before invoking the
compile() method. The order in which parameters are added is
significant. The appropriate execute or update
method can then be invoked.
SqlQuery, SqlUpdate, StoredProcedure, org.springframework.jdbc.core.JdbcTemplate
| Modifier and Type | Field and Description |
|---|---|
| private volatile boolean | compiled
Has this operation been compiled? |
| private final List | |
| private String[] | |
| private JdbcTemplate | jdbcTemplate
Lower-level class used to execute SQL. |
| protected final Log | logger
Logger available to subclasses. |
| private int | |
| private boolean | |
| private String | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. Ensures compilation if used in a bean factory. |
| protected boolean | allowsUnusedParameters()
Return whether this operation accepts additional parameters that are given but not actually used. |
| protected void | checkCompiled()
Check whether this operation has been compiled already; lazily compile it if not already compiled. |
| public final void | |
| protected abstract void | |
| public void | declareParameter(SqlParameter
the SqlParameter to add. This will specify SQL type and (optionally)
the parameter's name. Note that you typically use the param)SqlParameter class
itself here, not any of its subclasses.Declare a parameter for this operation. |
| protected List | |
| public String[] | |
| public JdbcTemplate | |
| public int | |
| public String | |
| public boolean | Returns: whether this operation is compiled and ready to useIs this operation "compiled"? |
| public boolean | isReturnGeneratedKeys()
Return whether statements should be capable of returning auto-generated keys. |
| public boolean | |
| protected String | |
| public void | |
| public void | |
| public void | |
| public void | setJdbcTemplate(JdbcTemplate jdbcTemplate)
An alternative to the more commonly used |
| public void | |
| public void | setParameters(SqlParameter...
an array containing the declared parameters)SqlParameter objectsAdd one or more declared parameters. |
| public void | setQueryTimeout(int queryTimeout)
Set the query timeout for statements that this RDBMS operation executes. |
| public void | setResultSetType(int
the ResultSet type resultSetType)Set whether to use statements that return a specific type of ResultSet. |
| public void | setReturnGeneratedKeys(boolean returnGeneratedKeys)
Set whether prepared statements should be capable of returning auto-generated keys. |
| public void | |
| public void | setTypes(int[]
array of SQL types as defined in the
types)java.sql.Types classAdd anonymous parameters, specifying only their SQL types
as defined in the |
| public void | setUpdatableResults(boolean updatableResults)
Set whether to use statements that are capable of returning updatable ResultSets. |
| protected boolean | supportsLobParameters()
Return whether BLOB/CLOB parameters are supported for this kind of operation. |
| protected void | validateNamedParameters(Map<String, ?>
parameter Map supplied (may be parameters)null)Validate the named parameters passed to an execute method based on declared parameters. |
| private void | validateParameterCount(int
the number of actual parameters given suppliedParamCount, int the number of input parameters declared declaredInParamCount)Validate the given parameter count against the given declared parameters. |
| protected void | validateParameters(Object[]
the parameters supplied (may be parameters)null)Validate the parameters passed to an execute method based on declared parameters. |
| compiled | back to summary |
|---|---|
| private volatile boolean compiled Has this operation been compiled? Compilation means at least checking that a DataSource and sql have been provided, but subclasses may also implement their own custom validation. | |
| declaredParameters | back to summary |
|---|---|
| private final List<SqlParameter> declaredParameters | |
| generatedKeysColumnNames | back to summary |
|---|---|
| private String[] generatedKeysColumnNames
| |
| jdbcTemplate | back to summary |
|---|---|
| private JdbcTemplate jdbcTemplate Lower-level class used to execute SQL. | |
| logger | back to summary |
|---|---|
| protected final Log logger Logger available to subclasses. | |
| resultSetType | back to summary |
|---|---|
| private int resultSetType | |
| returnGeneratedKeys | back to summary |
|---|---|
| private boolean returnGeneratedKeys | |
| sql | back to summary |
|---|---|
| private String sql
| |
| updatableResults | back to summary |
|---|---|
| private boolean updatableResults | |
| RdbmsOperation | back to summary |
|---|---|
| public RdbmsOperation() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Implements org. Ensures compilation if used in a bean factory.
| |
| allowsUnusedParameters | back to summary |
|---|---|
| protected boolean allowsUnusedParameters() Return whether this operation accepts additional parameters that are given but not actually used. Applies in particular to parameter Maps. The default is
| |
| checkCompiled | back to summary |
|---|---|
| protected void checkCompiled() Check whether this operation has been compiled already; lazily compile it if not already compiled. Automatically called by
| |
| compile | back to summary |
|---|---|
| public final void compile() throws InvalidDataAccessApiUsageException Compile this query. Ignores subsequent attempts to compile.
| |
| compileInternal | back to summary |
|---|---|
| protected abstract void compileInternal() throws InvalidDataAccessApiUsageException Subclasses must implement this template method to perform their own compilation. Invoked after this base class's compilation is complete. Subclasses can assume that SQL and a DataSource have been supplied.
| |
| declareParameter | back to summary |
|---|---|
| public void declareParameter(SqlParameter param) throws InvalidDataAccessApiUsageException Declare a parameter for this operation. The order in which this method is called is significant when using positional parameters. It is not significant when using named parameters with named SqlParameter objects here; it remains significant when using named parameters in combination with unnamed SqlParameter objects here.
| |
| getDeclaredParameters | back to summary |
|---|---|
| protected List Return a list of the declared | |
| getGeneratedKeysColumnNames | back to summary |
|---|---|
| public String[] getGeneratedKeysColumnNames() Return the column names of the auto generated keys.
| |
| getJdbcTemplate | back to summary |
|---|---|
| public JdbcTemplate getJdbcTemplate() Return the | |
| getResultSetType | back to summary |
|---|---|
| public int getResultSetType() Return whether statements will return a specific type of ResultSet. | |
| getSql | back to summary |
|---|---|
| public String getSql() Subclasses can override this to supply dynamic SQL if they wish, but SQL is
normally set by calling the
| |
| isCompiled | back to summary |
|---|---|
| public boolean isCompiled() Is this operation "compiled"? Compilation, as in JDO, means that the operation is fully configured, and ready to use. The exact meaning of compilation will vary between subclasses.
| |
| isReturnGeneratedKeys | back to summary |
|---|---|
| public boolean isReturnGeneratedKeys() Return whether statements should be capable of returning auto-generated keys. | |
| isUpdatableResults | back to summary |
|---|---|
| public boolean isUpdatableResults() Return whether statements will return updatable ResultSets. | |
| resolveSql | back to summary |
|---|---|
| protected String resolveSql() Resolve the configured SQL for actual use.
| |
| setDataSource | back to summary |
|---|---|
| public void setDataSource(DataSource dataSource) Set the JDBC | |
| setFetchSize | back to summary |
|---|---|
| public void setFetchSize(int fetchSize) Set the fetch size for this RDBMS operation. This is important for processing large result sets: Setting this higher than the default value will increase processing speed at the cost of memory consumption; setting this lower can avoid transferring row data that will never be read by the application. Default is -1, indicating to use the driver's default. | |
| setGeneratedKeysColumnNames | back to summary |
|---|---|
| public void setGeneratedKeysColumnNames(String... names) Set the column names of the auto-generated keys. | |
| setJdbcTemplate | back to summary |
|---|---|
| public void setJdbcTemplate(JdbcTemplate jdbcTemplate) An alternative to the more commonly used | |
| setMaxRows | back to summary |
|---|---|
| public void setMaxRows(int maxRows) Set the maximum number of rows for this RDBMS operation. This is important for processing subsets of large result sets, avoiding to read and hold the entire result set in the database or in the JDBC driver. Default is -1, indicating to use the driver's default. | |
| setParameters | back to summary |
|---|---|
| public void setParameters(SqlParameter... parameters) Add one or more declared parameters. Used for configuring this operation when used in a bean factory. Each parameter will specify SQL type and (optionally) the parameter's name.
| |
| setQueryTimeout | back to summary |
|---|---|
| public void setQueryTimeout(int queryTimeout) Set the query timeout for statements that this RDBMS operation executes. Default is -1, indicating to use the JDBC driver's default. Note Any timeout specified here will be overridden by the remaining transaction timeout when executing within a transaction that has a timeout specified at the transaction level. | |
| setResultSetType | back to summary |
|---|---|
| public void setResultSetType(int resultSetType) Set whether to use statements that return a specific type of ResultSet.
| |
| setReturnGeneratedKeys | back to summary |
|---|---|
| public void setReturnGeneratedKeys(boolean returnGeneratedKeys) Set whether prepared statements should be capable of returning auto-generated keys. | |
| setSql | back to summary |
|---|---|
| public void setSql(String sql) Set the SQL executed by this operation. | |
| setTypes | back to summary |
|---|---|
| public void setTypes(int[] types) throws InvalidDataAccessApiUsageException Add anonymous parameters, specifying only their SQL types
as defined in the Parameter ordering is significant. This method is an alternative
to the
| |
| setUpdatableResults | back to summary |
|---|---|
| public void setUpdatableResults(boolean updatableResults) Set whether to use statements that are capable of returning updatable ResultSets. | |
| supportsLobParameters | back to summary |
|---|---|
| protected boolean supportsLobParameters() Return whether BLOB/CLOB parameters are supported for this kind of operation. The default is | |
| validateNamedParameters | back to summary |
|---|---|
| protected void validateNamedParameters(Map<String, ?> parameters) throws InvalidDataAccessApiUsageException Validate the named parameters passed to an execute method based on declared parameters.
Subclasses should invoke this method before every
| |
| validateParameterCount | back to summary |
|---|---|
| private void validateParameterCount(int suppliedParamCount, int declaredInParamCount) Validate the given parameter count against the given declared parameters.
| |
| validateParameters | back to summary |
|---|---|
| protected void validateParameters(Object[] parameters) throws InvalidDataAccessApiUsageException Validate the parameters passed to an execute method based on declared parameters.
Subclasses should invoke this method before every
| |