public class NamedJdbcTemplate extends Object
| Constructor and Description |
|---|
NamedJdbcTemplate(DataSource dataSource) |
| Modifier and Type | Method and Description |
|---|---|
<T> int |
executeBatchInsert(String query,
NamedQueryFilter namedQueryFilter,
T bean)
Executes the jdbc insert/update query.
|
<T> int |
executeInsert(String query,
NamedQueryFilter namedQueryFilter,
T bean,
boolean fetchInsertedId)
Executes the jdbc insert/update query.
|
<T> List<T> |
executeQuery(String query,
RowMapper<T> rowMapper)
Executes a query on JDBC and return the result as a list of domain objects.
|
<T> List<T> |
executeQuery(String query,
RowMapper<T> rowMapper,
NamedQueryFilter namedQueryFilter)
Executes a query on JDBC and return the result as a list of domain objects.
|
int |
executeUpdate(String query)
Executes the jdbc update query and returns the result as updated id integer.
|
void |
executeUpdate(String query,
NamedQueryFilter namedQueryFilter)
Executes the jdbc update query and returns nothing.
|
<T> T |
fetchSingleRecord(String query,
RowMapper<T> rowMapper,
NamedQueryFilter namedQueryFilter)
Executes a query on JDBC and return the result as a domain object.
|
String |
getDatabaseProductName()
Retrieve database product name from the data source.
|
String |
getDriverName() |
<T,E extends Exception> |
withTransaction(NamedExecuteCallable<T> callable)
Provides the transaction support for the JDBC executions of the template.
|
public NamedJdbcTemplate(DataSource dataSource)
public <T,E extends Exception> T withTransaction(NamedExecuteCallable<T> callable) throws TransactionException, E extends Exception
callable - the SQL query execution method call.TransactionExceptionE extends Exceptionpublic <T> List<T> executeQuery(String query, RowMapper<T> rowMapper) throws DataAccessException
query - the SQL query with the parameter placeholders.rowMapper - Row mapper functional interface.DataAccessExceptionexecuteQuery(String, RowMapper, NamedQueryFilter)public <T> List<T> executeQuery(String query, RowMapper<T> rowMapper, NamedQueryFilter namedQueryFilter) throws DataAccessException
query - the SQL query with the parameter placeholders.rowMapper - Row mapper functional interface.namedQueryFilter - parameters for the SQL query parameter replacement.DataAccessExceptionpublic <T> T fetchSingleRecord(String query, RowMapper<T> rowMapper, NamedQueryFilter namedQueryFilter) throws DataAccessException
query - the SQL query with the parameter placeholders.rowMapper - Row mapper functional interface.namedQueryFilter - parameters for the SQL query parameter replacement.DataAccessExceptionpublic void executeUpdate(String query, NamedQueryFilter namedQueryFilter) throws DataAccessException
query - SQL query with the parameter placeholders.namedQueryFilter - parameters for the SQL query parameter replacement.DataAccessExceptionpublic int executeUpdate(String query) throws DataAccessException
query - the SQL query with the parameter placeholders.DataAccessExceptionpublic <T> int executeInsert(String query, NamedQueryFilter namedQueryFilter, T bean, boolean fetchInsertedId) throws DataAccessException
T - return type of the object.query - The SQL for insert/update.namedQueryFilter - Query filter to named prepared statement parameter binding.bean - the Domain object to be inserted/updated.DataAccessExceptionpublic <T> int executeBatchInsert(String query, NamedQueryFilter namedQueryFilter, T bean) throws DataAccessException
query - The SQL for insert/update.namedQueryFilter - Query filter to named prepared statement parameter binding.bean - the Domain object to be inserted/updated.DataAccessExceptionpublic String getDriverName() throws DataAccessException
DataAccessExceptionpublic String getDatabaseProductName() throws DataAccessException
DataAccessException - if an error occurs while retrieving metadata from data source.Copyright © 2022 WSO2. All rights reserved.