public class EmpireTemplate extends Object implements org.springframework.beans.factory.InitializingBean
JdbcTemplate
.Constructor and Description |
---|
EmpireTemplate()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
deleteRecord(DBRecord record)
Deletes a given record from the database.
|
void |
deleteRecord(DBTable table,
Object key)
Deletes a record from a table with a given single primary key.
|
void |
deleteRecord(DBTable table,
Object[] keys)
Deletes a record from a table with a given multiple primary key.
|
<K> K |
execute(org.springframework.jdbc.core.ConnectionCallback<K> connectionCallback)
Executes a ConnectionCallback.
|
int |
executeDelete(DBTable table,
DBCommand cmd)
Executes a Delete statement from a command object.
|
int |
executeInsert(DBCommand cmd)
Executes an Insert statement from a command object.
|
int |
executeUpdate(DBCommand cmd)
Executes an Update statement from a command object.
|
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
DBRecord |
getRecord(DBRowSet table,
Object key)
Opens a DBRecord instance with the given single primary key.
|
DBRecord |
getRecord(DBRowSet table,
Object[] keys)
Opens a DBRecord instance with the given multiple primary keys.
|
DBRecord |
newRecord(DBRowSet table)
Helper method to an create a DBRecord instance.
|
DBRecord |
openRecord(DBRowSet table,
Object key)
Opens a DBRecord instance with the given multiple primary keys.
|
DBRecord |
openRecord(DBRowSet table,
Object[] keys)
Opens a DBRecord instance with the given multiple primary keys.
|
<K> K |
query(DBCommand cmd,
DBReaderExtractor<K> readerExtractor)
Executes a given DBCommand and handles the DBReader with the provided
DBReaderExtractor.
|
void |
query(DBCommand cmd,
DBRecordCallbackHandler recordCallbackHandler)
Executes a given DBCommand and handles each row of the DBReader with the
provided DBRecordCallbackHandler.
|
<K> List<K> |
query(DBCommand cmd,
DBRecordMapper<K> recordMapper)
Executes a given DBCommand, mapping each row to a Java object via a
DBRecordMapper.
|
<T> T |
queryForBean(DBCommand cmd,
Class<T> t)
Executes a given DBCommand query and maps a single row to Class
|
<C extends Collection<T>,T> |
queryForBeanList(DBCommand cmd,
C c,
Class<T> t,
int maxCount)
Executes a given DBCommand query and maps each row to Class
|
<T> List<T> |
queryForBeanList(DBCommand cmd,
Class<T> t)
Executes a given DBCommand query and maps each row to Class
|
<T> List<T> |
queryForBeanList(DBCommand cmd,
Class<T> t,
int maxItems)
Executes a given DBCommand query and maps each row to Class
|
Integer |
queryForInteger(DBCommand cmd,
DBColumnExpr col,
Integer defaultValue)
Executes a given DBCommand, mapping a single column to a single Integer.
|
List<Integer> |
queryForIntegerList(DBCommand cmd,
DBColumnExpr col,
Integer defaultValue)
Executes a given DBCommand, extracting a single column to a List of
Integers.
|
List<Object> |
queryForList(DBCommand cmd,
DBColumnExpr col)
Executes a given DBCommand, mapping a single column to a Java object
using on DBRecordData.getValue() method.
|
Long |
queryForLong(DBCommand cmd,
DBColumnExpr col,
Long defaultValue)
Executes a given DBCommand, mapping a single column to a single Long.
|
List<Long> |
queryForLongList(DBCommand cmd,
DBColumnExpr col,
Long defaultValue)
Executes a given DBCommand, extracting a single column to a List of Long.
|
<K> K |
queryForObject(DBCommand cmd,
DBRecordMapper<K> recordMapper)
Executes a given DBCommand, mapping a single row to a Java object using
the provided DBRecordMapper.
|
String |
queryForString(DBCommand cmd,
DBColumnExpr col)
Executes a given DBCommand, mapping a single column to a single String.
|
List<String> |
queryForStringList(DBCommand cmd,
DBColumnExpr col)
Executes a given DBCommand, extracting a single column to a List of
Strings.
|
void |
setDataSource(DataSource dataSource)
Setting the datasource
|
void |
setDBReaderClass(Class<? extends DBReader> readerClass)
Setting a custom DBReader class to use in queries.
|
void |
setDBReaderFactory(org.springframework.beans.factory.ObjectFactory<DBReader> readerFactory)
Setting a custom ObjectFactory to allow custom DBReaders to use in
queries.
|
void |
setDBRecordClass(Class<? extends DBRecord> recordClass)
Setting a custom DBRecord class to use in newRecord().
|
void |
setDBRecordFactory(org.springframework.beans.factory.ObjectFactory<DBRecord> recordFactory)
Setting a custom ObjectFactory to allow custom DBRecord create with
newRecord().
|
void |
setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Setting the wrapped JdbcTemplate
|
DBRecord |
updateRecord(DBRecord record)
Updates the record and saves all changes in the database.
|
public void setDBRecordFactory(org.springframework.beans.factory.ObjectFactory<DBRecord> recordFactory)
recordFactory
- public void setDBRecordClass(Class<? extends DBRecord> recordClass)
recordClass
- the class which extends DBRecord.classpublic void setDBReaderFactory(org.springframework.beans.factory.ObjectFactory<DBReader> readerFactory)
readerFactory
- public void setDBReaderClass(Class<? extends DBReader> readerClass)
readerClass
- the class which extends DBReader.classpublic void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
public final void setDataSource(DataSource dataSource)
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public <K> List<K> query(DBCommand cmd, DBRecordMapper<K> recordMapper)
cmd
- the DBCommand to executerecordMapper
- the mapper which maps each DBRecordData to a Java objectpublic <K> K queryForObject(DBCommand cmd, DBRecordMapper<K> recordMapper)
cmd
- the DBCommand to executerecordMapper
- the DBRecordMapper to maporg.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one result object has been foundpublic List<Object> queryForList(DBCommand cmd, DBColumnExpr col)
cmd
- the DBCommand to executecol
- the column to mappublic Long queryForLong(DBCommand cmd, DBColumnExpr col, Long defaultValue)
cmd
- the DBCommand to executecol
- the column to mapdefaultValue
- the value to return in case of the database value is nullorg.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one result object has been foundpublic List<Long> queryForLongList(DBCommand cmd, DBColumnExpr col, Long defaultValue)
cmd
- the DBCommand to executecol
- the column to mapdefaultValue
- the value to return in case of the database value is nullpublic Integer queryForInteger(DBCommand cmd, DBColumnExpr col, Integer defaultValue)
cmd
- the DBCommand to executecol
- the column to mapdefaultValue
- the value to return in case of the database value is nullorg.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one result object has been foundpublic List<Integer> queryForIntegerList(DBCommand cmd, DBColumnExpr col, Integer defaultValue)
cmd
- the DBCommand to executecol
- the column to mapdefaultValue
- the value to return in case of the database value is nullpublic String queryForString(DBCommand cmd, DBColumnExpr col)
cmd
- the DBCommand to executecol
- the column to maporg.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one result object has been foundpublic List<String> queryForStringList(DBCommand cmd, DBColumnExpr col)
cmd
- the DBCommand to executecol
- the column to mappublic <K> K query(DBCommand cmd, DBReaderExtractor<K> readerExtractor)
cmd
- the DBCommand to executereaderExtractor
- public void query(DBCommand cmd, DBRecordCallbackHandler recordCallbackHandler)
cmd
- the DBCommand to executerecordCallbackHandler
- public void deleteRecord(DBRecord record)
record
- to deleteDBRecord.delete(Connection)
public void deleteRecord(DBTable table, Object key)
table
- the table to delete fromkey
- the primary keypublic void deleteRecord(DBTable table, Object[] keys)
table
- the table to delete fromkeys
- the primary keys arrayorg.apache.empire.db.DBTable.deleteRecord(Object[], Connection)
public DBRecord updateRecord(DBRecord record)
record
- to updateDBRecord.update(Connection)
public int executeUpdate(DBCommand cmd)
cmd
- the command object containing the update commandDBDatabase.executeUpdate(DBCommand, Connection)
public int executeDelete(DBTable table, DBCommand cmd)
cmd
- the command object containing the delete commandorg.apache.empire.db.DBDatabase#executeDelete(DBCommand, Connection)
public int executeInsert(DBCommand cmd)
cmd
- the command object containing the insert commandDBDatabase.executeInsert(DBCommand, Connection)
public DBRecord newRecord(DBRowSet table)
table
- the tablepublic DBRecord openRecord(DBRowSet table, Object key)
table
- the table to read the record fromkey
- the primary keyRecordNotFoundException
- in case of the record not foundpublic DBRecord openRecord(DBRowSet table, Object[] keys)
table
- the table to read the record fromkeys
- the primary key arrayRecordNotFoundException
- in case of the record not foundpublic DBRecord getRecord(DBRowSet table, Object key)
table
- the table to read the record fromkey
- the primary keypublic DBRecord getRecord(DBRowSet table, Object[] keys)
table
- the table to read the record fromkeys
- the primary keys arraypublic <C extends Collection<T>,T> C queryForBeanList(DBCommand cmd, C c, Class<T> t, int maxCount)
cmd
- the query commandc
- the collection to add the objects tot
- the class type of the objects in the listmaxCount
- the maximum number of objectsorg.apache.empire.db.DBReader.getBeanList(C, Class, int)
public <T> List<T> queryForBeanList(DBCommand cmd, Class<T> t, int maxItems)
cmd
- the query commandt
- the class type of the objects in the listmaxCount
- the maximum number of objectsorg.apache.empire.db.DBReader.getBeanList(Class, int)
public <T> List<T> queryForBeanList(DBCommand cmd, Class<T> t)
cmd
- the query commandt
- the class type of the objects in the listorg.apache.empire.db.DBReader.getBeanList(Class)
public <T> T queryForBean(DBCommand cmd, Class<T> t)
cmd
- the query commandt
- the class type of the object to returnorg.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one result object has been foundpublic <K> K execute(org.springframework.jdbc.core.ConnectionCallback<K> connectionCallback)
connectionCallback
- org.springframework.jdbc.core.JdbcTemplate.execute(ConnectionCallback
)
Copyright © 2008–2022 Apache Software Foundation. All rights reserved.