public abstract class StatementExecutor<E> extends Object implements AbstractDAO<E>
Modifier and Type | Field and Description |
---|---|
protected Connection |
connection |
protected static String |
PARAMETER |
protected static String |
PARAMETER_COMMA |
protected static String |
SQL_COUNT_ALL_PREFIX |
protected static String |
WHERE |
Modifier | Constructor and Description |
---|---|
protected |
StatementExecutor(Connection con) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToCache(String key,
E elt) |
protected void |
clearCache() |
void |
close() |
protected void |
closeResultSet(ResultSet rs) |
protected void |
closeStatement(Statement stm) |
long |
count(List<Filter> filters)
Count all objects corresponding to the given filters
from the persistance layer
|
void |
delete(E e1)
Remove the specified object from the persistance layer
|
int |
delete(List<Filter> filters)
Delete all items according to filter
|
void |
deleteAll()
Remove all objects from the persistance layer
|
protected int |
executeAction(PreparedStatement stm) |
protected ResultSet |
executeQuery(PreparedStatement stm) |
protected void |
executeUpdate(PreparedStatement stm) |
boolean |
exist(String id)
Verify if an object with the specified id exists in the
persistance layer
|
List<E> |
find(List<Filter> filters)
Retrieve all objects corresponding to the given filters in a List
from the persistance layer
|
List<E> |
find(List<Filter> filters,
int limit)
Retrieve all objects corresponding to the given filters in a List
from the persistance layer
|
List<E> |
find(List<Filter> filters,
String field,
boolean asc)
Retrieve all objects corresponding to the given filters in a List
from the persistance layer
|
List<E> |
find(List<Filter> filters,
String field,
boolean asc,
int limit)
Retrieve all objects corresponding to the given filters in a List
from the persistance layer
|
List<E> |
find(List<Filter> filters,
String field,
boolean asc,
int limit,
int offset)
Retrieve all objects corresponding to the given filters in a List
from the persistance layer
|
List<E> |
getAll()
Retrieve all objects in a List from the persistance layer
|
protected SynchronizedLruCache<String,E> |
getCache() |
Connection |
getConnection() |
protected abstract String |
getCountRequest() |
protected abstract String |
getDeleteAllRequest() |
protected abstract String |
getDeleteRequest() |
protected abstract String |
getExistRequest() |
protected E |
getFromCache(String key) |
abstract E |
getFromResultSet(ResultSet set) |
protected abstract String |
getGetAllRequest() |
protected abstract String |
getId(E e1) |
protected abstract String |
getInsertRequest() |
protected abstract Object[] |
getInsertValues(E e1) |
protected abstract String |
getSelectRequest() |
protected abstract String |
getTable() |
protected abstract String |
getUpdateRequest() |
protected abstract Object[] |
getUpdateValues(E e1) |
void |
insert(E e1)
Insert the specified object in the persistance layer
|
protected abstract boolean |
isCachedEnable() |
protected abstract boolean |
isDbTransfer() |
protected boolean |
isInCache(String key) |
protected String |
prepareCountQuery(List<Filter> filters,
Object[] params) |
protected String |
prepareDeleteQuery(List<Filter> filters,
Object[] params) |
protected Object[] |
prepareFindParams(List<Filter> filters) |
protected String |
prepareFindQuery(List<Filter> filters,
Object[] params) |
protected void |
removeFromCache(String key) |
E |
select(String id)
Retrieve the object with the specified id from the persistance
layer
|
protected void |
setParameters(PreparedStatement stm,
Object... values) |
void |
update(E e1)
Update the specified object in the persistance layer
|
void |
update(List<Filter> filters,
String fieldToSet)
Update all objects corresponding to the given filters in a List
from the persistance layer
|
protected static final String WHERE
protected static final String PARAMETER
protected static final String PARAMETER_COMMA
protected static final String SQL_COUNT_ALL_PREFIX
protected Connection connection
protected StatementExecutor(Connection con)
protected abstract boolean isDbTransfer()
public abstract E getFromResultSet(ResultSet set) throws SQLException, DAOConnectionException
SQLException
DAOConnectionException
protected abstract boolean isCachedEnable()
protected SynchronizedLruCache<String,E> getCache()
protected final void clearCache()
protected final void removeFromCache(String key)
protected final boolean isInCache(String key)
public Connection getConnection()
protected final void setParameters(PreparedStatement stm, Object... values) throws SQLException
SQLException
protected final void executeUpdate(PreparedStatement stm) throws SQLException
SQLException
protected final int executeAction(PreparedStatement stm) throws SQLException
SQLException
protected final ResultSet executeQuery(PreparedStatement stm) throws SQLException
SQLException
protected final void closeStatement(Statement stm)
protected final void closeResultSet(ResultSet rs)
public final void close()
close
in interface AbstractDAO<E>
protected abstract String getTable()
protected abstract String getSelectRequest()
protected abstract String getCountRequest()
protected abstract String getGetAllRequest()
protected abstract String getExistRequest()
protected abstract Object[] getInsertValues(E e1) throws WaarpDatabaseSqlException
WaarpDatabaseSqlException
protected abstract String getInsertRequest()
protected abstract Object[] getUpdateValues(E e1) throws WaarpDatabaseSqlException
WaarpDatabaseSqlException
protected abstract String getUpdateRequest()
protected abstract String getDeleteRequest()
protected abstract String getDeleteAllRequest()
public void delete(E e1) throws DAOConnectionException, DAONoDataException
AbstractDAO
delete
in interface AbstractDAO<E>
e1
- object to deleteDAOConnectionException
- If a data access error occursDAONoDataException
- if no data are availablepublic final void deleteAll() throws DAOConnectionException
AbstractDAO
deleteAll
in interface AbstractDAO<E>
DAOConnectionException
- If a data access error occurspublic final int delete(List<Filter> filters) throws DAOConnectionException
filters
- DAOConnectionException
public final List<E> getAll() throws DAOConnectionException
AbstractDAO
getAll
in interface AbstractDAO<E>
DAOConnectionException
- If data access error occurspublic final List<E> find(List<Filter> filters) throws DAOConnectionException
AbstractDAO
find
in interface AbstractDAO<E>
filters
- List of filterDAOConnectionException
- If data access error occurspublic final List<E> find(List<Filter> filters, int limit) throws DAOConnectionException
AbstractDAO
find
in interface AbstractDAO<E>
filters
- List of filterlimit
- max number of items to getDAOConnectionException
- If data access error occurspublic final List<E> find(List<Filter> filters, String field, boolean asc) throws DAOConnectionException
AbstractDAO
find
in interface AbstractDAO<E>
filters
- List of filterfield
- field to sort onasc
- True for ascending, False for descending orderDAOConnectionException
- If data access error occurspublic final List<E> find(List<Filter> filters, String field, boolean asc, int limit) throws DAOConnectionException
AbstractDAO
find
in interface AbstractDAO<E>
filters
- List of filterfield
- field to sort onasc
- True for ascending, False for descending orderlimit
- max number of items to getDAOConnectionException
- If data access error occurspublic final List<E> find(List<Filter> filters, String field, boolean asc, int limit, int offset) throws DAOConnectionException
AbstractDAO
find
in interface AbstractDAO<E>
filters
- List of filterfield
- field to sort onasc
- True for ascending, False for descending orderlimit
- max number of items to getoffset
- start for items to getDAOConnectionException
- If data access error occurspublic final void update(List<Filter> filters, String fieldToSet) throws DAOConnectionException
AbstractDAO
update
in interface AbstractDAO<E>
filters
- List of filterfieldToSet
- field to update as "field1 = value1, field2 = value2, ..."DAOConnectionException
- If data access error occurspublic final long count(List<Filter> filters) throws DAOConnectionException
AbstractDAO
count
in interface AbstractDAO<E>
filters
- List of filterDAOConnectionException
- If data access error occurspublic final boolean exist(String id) throws DAOConnectionException
AbstractDAO
exist
in interface AbstractDAO<E>
id
- id of the object verifiedDAOConnectionException
- If a data access error occurspublic final E select(String id) throws DAOConnectionException, DAONoDataException
AbstractDAO
select
in interface AbstractDAO<E>
id
- id of the object requestedDAOConnectionException
- If a data access error occursDAONoDataException
- if no data are availablepublic void insert(E e1) throws DAOConnectionException
AbstractDAO
insert
in interface AbstractDAO<E>
e1
- object to insertDAOConnectionException
- If a data access error occurspublic final void update(E e1) throws DAOConnectionException, DAONoDataException
AbstractDAO
update
in interface AbstractDAO<E>
e1
- object to updateDAOConnectionException
- If a data access error occursDAONoDataException
- if no data are availableCopyright © 2009–2022 Waarp. All rights reserved.