public class CommonDAO
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
CommonDAO.ObjectExtractor<T> |
protected static class |
CommonDAO.RecordUpdater<T extends Id> |
Modifier and Type | Field and Description |
---|---|
protected java.sql.Connection |
con |
protected java.text.DateFormat |
dateFormat_DDMMYYYY |
protected java.text.DateFormat |
dateFormat_DDMMYYYY_HHMM |
protected Logger |
log |
protected static java.lang.String |
SQL_AND |
protected static java.lang.String |
SQL_DELETE |
protected static java.lang.String |
SQL_DESC |
protected static java.lang.String |
SQL_FROM |
protected static java.lang.String |
SQL_GROUP_BY |
protected static java.lang.String |
SQL_INNER_JOIN |
protected static java.lang.String |
SQL_INSERT |
protected static java.lang.String |
SQL_INSERT_IGNORE |
protected static java.lang.String |
SQL_LEFT_JOIN |
protected static java.lang.String |
SQL_LEFT_OUTER_JOIN |
protected static java.lang.String |
SQL_LIMIT |
protected static java.lang.String |
SQL_ON_DUP_KEY_UPDATE |
protected static java.lang.String |
SQL_OR |
protected static java.lang.String |
SQL_ORDER_BY |
protected static java.lang.String |
SQL_REPLACE |
protected static java.lang.String |
SQL_SELECT |
protected static java.lang.String |
SQL_SELECT_ALL_FROM |
protected static java.lang.String |
SQL_SELECT_COUNT_ROWS |
protected static java.lang.String |
SQL_SET |
protected static java.lang.String |
SQL_UPDATE |
protected static java.lang.String |
SQL_WHERE |
Modifier | Constructor and Description |
---|---|
protected |
CommonDAO(java.sql.Connection con) |
Modifier and Type | Method and Description |
---|---|
protected void |
deleteById(java.lang.String tableName,
int id) |
protected <T> SearchResult<T> |
execute(SearchResult<T> result,
java.lang.String query,
ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare,
ThrowableFunction<java.sql.ResultSet,java.util.Collection<T>,java.sql.SQLException> builder) |
protected <T> T |
execute(java.lang.String query,
ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare,
ThrowableFunction<java.sql.ResultSet,T,java.sql.SQLException> builder) |
protected <T> T |
execute(java.lang.String query,
ThrowableFunction<java.sql.ResultSet,T,java.sql.SQLException> builder) |
protected int |
executeInsert(java.lang.String query,
ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare) |
protected int |
executeUpdate(java.lang.String query,
ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare) |
protected <T> T |
getById(java.lang.String tableName,
int id,
CommonDAO.ObjectExtractor<T> extractor) |
protected int |
getFoundRows(java.sql.Connection con) |
protected int |
getFoundRows(java.sql.PreparedStatement ps) |
protected java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> |
getGroupedIds(java.lang.String tableName,
java.lang.String linkColumn,
java.lang.String selectColumn) |
protected java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> |
getGroupedIds(java.lang.String tableName,
java.lang.String linkColumn,
java.lang.String selectColumn,
java.lang.String posColumn) |
protected java.util.Set<java.lang.Integer> |
getIds(java.lang.String tableName,
java.lang.String linkColumn,
java.lang.String selectColumn,
int id) |
protected java.util.List<java.lang.Integer> |
getIds(java.lang.String tableName,
java.lang.String linkColumn,
java.lang.String selectColumn,
java.lang.String posColumn,
int id) |
static java.lang.String |
getLikePattern(java.lang.String substring,
java.lang.String mode) |
static java.lang.String |
getLikePatternEnd(java.lang.String substring) |
static java.lang.String |
getLikePatternStart(java.lang.String substring) |
static java.lang.String |
getLikePatternSub(java.lang.String substring) |
protected java.lang.String |
getMySQLLimit(Page page) |
protected java.lang.String |
getPeriodSql(Period period,
java.lang.String fieldName) |
protected int |
lastInsertId(java.sql.PreparedStatement ps) |
protected int |
setPeriodParamValue(Period period,
java.sql.PreparedStatement ps,
int index) |
protected void |
setRecordCount(Page page,
java.sql.PreparedStatement ps) |
protected void |
sqlToBgException(java.sql.SQLException e) |
protected <T extends Id> |
update(T record,
CommonDAO.RecordUpdater<T> updater) |
void |
updateColumn(java.lang.String tableName,
int id,
java.lang.String columnName,
java.lang.String value) |
protected void |
updateIds(java.lang.String tableName,
java.lang.String linkColumn,
java.lang.String valueColumn,
java.lang.Object id,
java.util.Set<java.lang.Integer> values) |
protected void |
updateIds(java.lang.String tableName,
java.lang.String linkColumn,
java.lang.String valueColumn,
java.lang.String posColumn,
int id,
java.util.List<java.lang.Integer> values) |
protected static final java.lang.String SQL_SELECT
protected static final java.lang.String SQL_SELECT_ALL_FROM
protected static final java.lang.String SQL_SELECT_COUNT_ROWS
protected static final java.lang.String SQL_INSERT_IGNORE
protected static final java.lang.String SQL_INSERT
protected static final java.lang.String SQL_SET
protected static final java.lang.String SQL_UPDATE
protected static final java.lang.String SQL_DELETE
protected static final java.lang.String SQL_FROM
protected static final java.lang.String SQL_LEFT_JOIN
protected static final java.lang.String SQL_LEFT_OUTER_JOIN
protected static final java.lang.String SQL_INNER_JOIN
protected static final java.lang.String SQL_WHERE
protected static final java.lang.String SQL_ORDER_BY
protected static final java.lang.String SQL_GROUP_BY
protected static final java.lang.String SQL_AND
protected static final java.lang.String SQL_OR
protected static final java.lang.String SQL_LIMIT
protected static final java.lang.String SQL_DESC
protected static final java.lang.String SQL_REPLACE
protected static final java.lang.String SQL_ON_DUP_KEY_UPDATE
protected java.text.DateFormat dateFormat_DDMMYYYY
protected java.text.DateFormat dateFormat_DDMMYYYY_HHMM
protected Logger log
protected java.sql.Connection con
protected int lastInsertId(java.sql.PreparedStatement ps) throws java.sql.SQLException
java.sql.SQLException
protected int getFoundRows(java.sql.PreparedStatement ps) throws java.sql.SQLException
java.sql.SQLException
protected int getFoundRows(java.sql.Connection con) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.String getLikePattern(java.lang.String substring, java.lang.String mode)
public static java.lang.String getLikePatternSub(java.lang.String substring)
public static java.lang.String getLikePatternStart(java.lang.String substring)
public static java.lang.String getLikePatternEnd(java.lang.String substring)
protected java.lang.String getMySQLLimit(Page page)
protected void setRecordCount(Page page, java.sql.PreparedStatement ps) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.String getPeriodSql(Period period, java.lang.String fieldName)
protected int setPeriodParamValue(Period period, java.sql.PreparedStatement ps, int index) throws java.sql.SQLException
java.sql.SQLException
protected java.util.Set<java.lang.Integer> getIds(java.lang.String tableName, java.lang.String linkColumn, java.lang.String selectColumn, int id) throws BGException
BGException
protected java.util.List<java.lang.Integer> getIds(java.lang.String tableName, java.lang.String linkColumn, java.lang.String selectColumn, java.lang.String posColumn, int id) throws BGException
BGException
protected java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> getGroupedIds(java.lang.String tableName, java.lang.String linkColumn, java.lang.String selectColumn) throws BGException
BGException
protected java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> getGroupedIds(java.lang.String tableName, java.lang.String linkColumn, java.lang.String selectColumn, java.lang.String posColumn) throws BGException
BGException
protected <T> T getById(java.lang.String tableName, int id, CommonDAO.ObjectExtractor<T> extractor) throws BGException
BGException
protected void deleteById(java.lang.String tableName, int id) throws BGException
BGException
protected <T extends Id> void update(T record, CommonDAO.RecordUpdater<T> updater) throws BGException
BGException
protected void updateIds(java.lang.String tableName, java.lang.String linkColumn, java.lang.String valueColumn, java.lang.Object id, java.util.Set<java.lang.Integer> values) throws BGException
BGException
protected void updateIds(java.lang.String tableName, java.lang.String linkColumn, java.lang.String valueColumn, java.lang.String posColumn, int id, java.util.List<java.lang.Integer> values) throws BGException
BGException
public void updateColumn(java.lang.String tableName, int id, java.lang.String columnName, java.lang.String value) throws BGException
BGException
protected void sqlToBgException(java.sql.SQLException e) throws BGException
BGException
protected <T> SearchResult<T> execute(SearchResult<T> result, java.lang.String query, ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare, ThrowableFunction<java.sql.ResultSet,java.util.Collection<T>,java.sql.SQLException> builder) throws BGException
BGException
protected <T> T execute(java.lang.String query, ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare, ThrowableFunction<java.sql.ResultSet,T,java.sql.SQLException> builder) throws BGException
BGException
protected <T> T execute(java.lang.String query, ThrowableFunction<java.sql.ResultSet,T,java.sql.SQLException> builder) throws BGException
BGException
protected int executeUpdate(java.lang.String query, ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare) throws BGException
BGException
protected int executeInsert(java.lang.String query, ThrowableConsumer<java.sql.PreparedStatement,java.sql.SQLException> prepare) throws BGException
BGException