Interface SqlMapExecutor
- All Known Subinterfaces:
ExtendedSqlMapClient
,SqlMapClient
,SqlMapSession
- All Known Implementing Classes:
SqlMapClientImpl
,SqlMapSessionImpl
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
Executes a mapped SQL DELETE statement.int
Executes a mapped SQL DELETE statement.int
Executes (flushes) all statements currently batched.Executes (flushes) all statements currently batched.Executes a mapped SQL INSERT statement.Executes a mapped SQL INSERT statement.queryForList
(String id) Executes a mapped SQL SELECT statement that returns data to populate a number of result objects.queryForList
(String id, int skip, int max) Executes a mapped SQL SELECT statement that returns data to populate a number of result objects within a certain range.queryForList
(String id, Object parameterObject) Executes a mapped SQL SELECT statement that returns data to populate a number of result objects.queryForList
(String id, Object parameterObject, int skip, int max) Executes a mapped SQL SELECT statement that returns data to populate a number of result objects within a certain range.queryForMap
(String id, Object parameterObject, String keyProp) Executes a mapped SQL SELECT statement that returns data to populate a number of result objects that will be keyed into a Map.queryForMap
(String id, Object parameterObject, String keyProp, String valueProp) Executes a mapped SQL SELECT statement that returns data to populate a number of result objects from which one property will be keyed into a Map.queryForObject
(String id) Executes a mapped SQL SELECT statement that returns data to populate a single object instance.queryForObject
(String id, Object parameterObject) Executes a mapped SQL SELECT statement that returns data to populate a single object instance.queryForObject
(String id, Object parameterObject, Object resultObject) Executes a mapped SQL SELECT statement that returns data to populate the supplied result object.queryForPaginatedList
(String id, int pageSize) Deprecated.All paginated list features have been deprecatedqueryForPaginatedList
(String id, Object parameterObject, int pageSize) Deprecated.All paginated list features have been deprecatedvoid
queryWithRowHandler
(String id, RowHandler rowHandler) Executes a mapped SQL SELECT statement that returns a number of result objects that will be handled one at a time by a RowHandler.void
queryWithRowHandler
(String id, Object parameterObject, RowHandler rowHandler) Executes a mapped SQL SELECT statement that returns a number of result objects that will be handled one at a time by a RowHandler.void
Starts a batch in which update statements will be cached before being sent to the database all at once.int
Executes a mapped SQL UPDATE statement.int
Executes a mapped SQL UPDATE statement.
-
Method Details
-
insert
Executes a mapped SQL INSERT statement. Insert is a bit different from other update methods, as it provides facilities for returning the primary key of the newly inserted row (rather than the effected rows). This functionality is of course optional.The parameter object is generally used to supply the input data for the INSERT values.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).- Returns:
- The primary key of the newly inserted row. This might be automatically generated by the RDBMS, or selected from a sequence table or other source.
- Throws:
SQLException
- the SQL exception
-
insert
Executes a mapped SQL INSERT statement. Insert is a bit different from other update methods, as it provides facilities for returning the primary key of the newly inserted row (rather than the effected rows). This functionality is of course optional.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.- Returns:
- The primary key of the newly inserted row. This might be automatically generated by the RDBMS, or selected from a sequence table or other source.
- Throws:
SQLException
- the SQL exception
-
update
Executes a mapped SQL UPDATE statement. Update can also be used for any other update statement type, such as inserts and deletes. Update returns the number of rows effected.The parameter object is generally used to supply the input data for the UPDATE values as well as the WHERE clause parameter(s).
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).- Returns:
- The number of rows effected.
- Throws:
SQLException
- the SQL exception
-
update
Executes a mapped SQL UPDATE statement. Update can also be used for any other update statement type, such as inserts and deletes. Update returns the number of rows effected.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.- Returns:
- The number of rows effected.
- Throws:
SQLException
- the SQL exception
-
delete
Executes a mapped SQL DELETE statement. Delete returns the number of rows effected.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the DELETE statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).- Returns:
- The number of rows effected.
- Throws:
SQLException
- the SQL exception
-
delete
Executes a mapped SQL DELETE statement. Delete returns the number of rows effected.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.- Returns:
- The number of rows effected.
- Throws:
SQLException
- the SQL exception
-
queryForObject
Executes a mapped SQL SELECT statement that returns data to populate a single object instance.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).- Returns:
- The single result object populated with the result set data, or null if no result was found
- Throws:
SQLException
- the SQL exception
-
queryForObject
Executes a mapped SQL SELECT statement that returns data to populate a single object instance.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.- Returns:
- The single result object populated with the result set data, or null if no result was found
- Throws:
SQLException
- the SQL exception
-
queryForObject
Executes a mapped SQL SELECT statement that returns data to populate the supplied result object.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).resultObject
- The result object instance that should be populated with result data.- Returns:
- The single result object as supplied by the resultObject parameter, populated with the result set data, or null if no result was found
- Throws:
SQLException
- the SQL exception
-
queryForList
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).- Returns:
- A List of result objects.
- Throws:
SQLException
- the SQL exception
-
queryForList
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.- Returns:
- A List of result objects.
- Throws:
SQLException
- the SQL exception
-
queryForList
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects within a certain range.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).skip
- The number of results to ignore.max
- The maximum number of results to return.- Returns:
- A List of result objects.
- Throws:
SQLException
- the SQL exception
-
queryForList
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects within a certain range.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.skip
- The number of results to ignore.max
- The maximum number of results to return.- Returns:
- A List of result objects.
- Throws:
SQLException
- the SQL exception
-
queryWithRowHandler
void queryWithRowHandler(String id, Object parameterObject, RowHandler rowHandler) throws SQLException Executes a mapped SQL SELECT statement that returns a number of result objects that will be handled one at a time by a RowHandler.This is generally a good approach to take when dealing with large sets of records (i.e. hundreds, thousands...) that need to be processed without eating up all of the system resources.
The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).rowHandler
- A RowHandler instance- Throws:
SQLException
- the SQL exception
-
queryWithRowHandler
Executes a mapped SQL SELECT statement that returns a number of result objects that will be handled one at a time by a RowHandler.This is generally a good approach to take when dealing with large sets of records (i.e. hundreds, thousands...) that need to be processed without eating up all of the system resources.
This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.rowHandler
- A RowHandler instance- Throws:
SQLException
- the SQL exception
-
queryForPaginatedList
PaginatedList queryForPaginatedList(String id, Object parameterObject, int pageSize) throws SQLException Deprecated.All paginated list features have been deprecatedExecutes a mapped SQL SELECT statement that returns data to populate a number of result objects a page at a time.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).pageSize
- The maximum number of result objects each page can hold.- Returns:
- A PaginatedList of result objects.
- Throws:
SQLException
- the SQL exception
-
queryForPaginatedList
Deprecated.All paginated list features have been deprecatedExecutes a mapped SQL SELECT statement that returns data to populate a number of result objects a page at a time.This overload assumes no parameter is needed.
- Parameters:
id
- The name of the statement to execute.pageSize
- The maximum number of result objects each page can hold.- Returns:
- A PaginatedList of result objects.
- Throws:
SQLException
- the SQL exception
-
queryForMap
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects that will be keyed into a Map.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).keyProp
- The property to be used as the key in the Map.- Returns:
- A Map keyed by keyProp with values being the result object instance.
- Throws:
SQLException
- the SQL exception
-
queryForMap
Map queryForMap(String id, Object parameterObject, String keyProp, String valueProp) throws SQLException Executes a mapped SQL SELECT statement that returns data to populate a number of result objects from which one property will be keyed into a Map.The parameter object is generally used to supply the input data for the WHERE clause parameter(s) of the SELECT statement.
- Parameters:
id
- The name of the statement to execute.parameterObject
- The parameter object (e.g. JavaBean, Map, XML etc.).keyProp
- The property to be used as the key in the Map.valueProp
- The property to be used as the value in the Map.- Returns:
- A Map keyed by keyProp with values of valueProp.
- Throws:
SQLException
- the SQL exception
-
startBatch
Starts a batch in which update statements will be cached before being sent to the database all at once. This can improve overall performance of updates update when dealing with numerous updates (e.g. inserting 1:M related data).- Throws:
SQLException
- the SQL exception
-
executeBatch
Executes (flushes) all statements currently batched.- Returns:
- the number of rows updated in the batch
- Throws:
SQLException
- the SQL exception
-
executeBatchDetailed
Executes (flushes) all statements currently batched.- Returns:
- a List of BatchResult objects. There will be one element in the list for each sub-batch executed. A sub-batch is created by adding a statement to the batch that does not equal the prior statement.
- Throws:
SQLException
- if a database access error occurs, or the drive does not support batch statementsBatchException
- if the driver throws BatchUpdateException- See Also:
-