public class AbstractSQLCommentsRepository
extends org.springframework.jdbc.core.support.JdbcDaoSupport
CRUD methods and findByPK
are expecting that some
configuration classes and statement files already exists. Use sqlcomments maven plugin with goal domain to
generate appropriate classes and files:
Constructor and Description |
---|
AbstractSQLCommentsRepository() |
Modifier and Type | Method and Description |
---|---|
protected CallableStatement |
createCallableStatement(Connection connection,
String statementName,
Map<String,Object> parameters)
Creates callable statement.
|
protected CallableStatement |
createCallableStatement(Connection connection,
String statementName,
Map<String,Object> parameters,
Set<String> acceptNullParameters)
Creates callable statement.
|
protected PreparedStatement |
createPreparedStatement(Connection connection,
StatementConfiguration configuration)
Creates prepared statement.
|
protected void |
delete(StatementConfiguration configuration)
Deletes record from database.
|
protected <T> void |
delete(T domain)
Deletes record from database.
|
protected void |
executeStatement(StatementConfiguration config)
Executes given statement.
|
protected <T> T |
findByPK(StatementConfiguration config,
ResultMapper<T> mapper)
Loads instance from database by primary key.
|
StatementContainer |
getStatementContainer()
Gets statement container.
|
protected <T> T |
insert(T domain)
Inserts instance to database.
|
protected <T> List<T> |
list(StatementConfiguration configuration,
ResultMapper<T> mapper)
Returns list of transformed query results.
|
void |
setDialect(DatabaseDialect dialect)
Sets database dialect to use.
|
void |
setStatementContainer(StatementContainer statementContainer)
Sets statement container.
|
protected <T> T |
singleResult(StatementConfiguration configuration,
ResultMapper<T> mapper)
Returns single row transformed into result object.
|
protected <T> void |
update(T domain)
Updates record in database.
|
protected <T> T findByPK(StatementConfiguration config, ResultMapper<T> mapper)
Configuration class is using SQL statement called findByPK which is generated for each domain class.
T
- instance classconfig
- statement configuration (usually class generated as a <T>PKConfig)mapper
- class mapperprotected <T> T insert(T domain)
Configuration class is using SQL statement called <T>.insert.sql which is generated for each domain class.
T
- instance classdomain
- domain class to be stored in DBprotected <T> void update(T domain)
Configuration class is using SQL statement called <T>.update.sql which is generated for each domain class.
T
- instance classdomain
- domain class to be stored in DBprotected <T> void delete(T domain)
Configuration class is using SQL statement called <T>.delete.sql which is generated for each domain class.
T
- instance classdomain
- domain to be removed from DBprotected void delete(StatementConfiguration configuration)
Configuration class is using SQL statement called <T>.delete.sql which is generated for each domain class.
configuration
- statement configuration (usually <T>PKConfig)protected <T> List<T> list(StatementConfiguration configuration, ResultMapper<T> mapper) throws StatementException
T
- result classconfiguration
- statement configurationmapper
- result mapperStatementException
- thrown if JDBC call or transformation failedprotected <T> T singleResult(StatementConfiguration configuration, ResultMapper<T> mapper) throws StatementException
T
- result classconfiguration
- statement configurationmapper
- result mapperStatementException
- thrown if JDBC call or transformation failed or non-unique resultprotected PreparedStatement createPreparedStatement(Connection connection, StatementConfiguration configuration)
As a base class is used this.
connection
- JDBC connection. Caller is responsible to return connection to pool if necessary.configuration
- statement configurationStatementException
- thrown if statement creation failedprotected CallableStatement createCallableStatement(Connection connection, String statementName, Map<String,Object> parameters) throws StatementException
As a base class is used this.
connection
- JDBC connectionstatementName
- statement simple nameparameters
- parametersStatementException
- thrown if statement creation failedprotected CallableStatement createCallableStatement(Connection connection, String statementName, Map<String,Object> parameters, Set<String> acceptNullParameters) throws StatementException
As a base class is used this.
connection
- JDBC connectionstatementName
- statement simple nameparameters
- parametersacceptNullParameters
- parameter names accepting null valuesStatementException
- thrown if statement creation failedprotected void executeStatement(StatementConfiguration config)
Method is intended for use with update and delete SQL statements.
config
- statement configurationPreparedStatement.execute()
public StatementContainer getStatementContainer()
public void setStatementContainer(StatementContainer statementContainer)
statementContainer
- statement containerpublic void setDialect(DatabaseDialect dialect)
dialect
- database dialectCopyright © 2014–2015 Vracon s.r.o.. All rights reserved.