Package ru.bgcrm.dao
Class CommonDAO
java.lang.Object
ru.bgcrm.dao.CommonDAO
- Direct Known Subclasses:
AbstractDAO,AddressDAO,AddressDistributionDAO,AppointmentDAO,BGBillingDAO,CannedMessageDAO,CommonContractDAO,CommonLinkDAO,ConfigDAO,ConfigHistoryDAO,ContractCustomerDAO,ContractLinkDAO,CounterDAO,CustomerDAO,CustomerGroupDAO,DetourDAO,DirectionDAO,DispatchDAO,DocumentDAO,EntityLogDAO,FileDataDAO,GsmDao,MessageDAO,MovementDAO,NewsDAO,NomenclatureDAO,NomenclatureLinkDao,ParamDAO,ParamGroupDAO,ParamLogDAO,ParamValueDAO,PatternDAO,PaymentDAO,PeriodicDAO,ProcessDAO,ProcessTypeDAO,QueueDAO,RealizationDAO,SavedFilterDAO,SegmentDAO,ShiftDAO,SimDAO,SphinxDAO,StatusChangeDAO,StatusDAO,StorageDAO,TabelDAO,TaskDAO,TmcDAO,TopicDAO,UserDAO,UserGroupDAO,VacancyDAO,WizardDAO,WorkTaskDAO,WorkTypeDAO
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceprotected static classCommonDAO.RecordUpdater<T extends Id> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connectionprotected DateFormatprotected DateFormatprotected ru.bgcrm.logging.Loggerprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildPlaceholders(int count) protected voiddeleteById(String tableName, int id) protected <T> Texecute(String query, ThrowableConsumer<PreparedStatement, SQLException> prepare, ThrowableFunction<ResultSet, T, SQLException> builder) protected <T> Texecute(String query, ThrowableFunction<ResultSet, T, SQLException> builder) protected <T> SearchResult<T> execute(SearchResult<T> result, String query, ThrowableConsumer<PreparedStatement, SQLException> prepare, ThrowableFunction<ResultSet, Collection<T>, SQLException> builder) protected int[]executeBatch(String query, ThrowableConsumer<PreparedStatement, SQLException> preparer) protected intexecuteInsert(String query, ThrowableConsumer<PreparedStatement, SQLException> prepare) protected intexecuteUpdate(String query, ThrowableConsumer<PreparedStatement, SQLException> prepare) protected <T> TgetById(String tableName, int id, CommonDAO.ObjectExtractor<T> extractor) protected intgetFoundRows(Connection con) protected intgetGroupedIds(String tableName, String linkColumn, String selectColumn) getGroupedIds(String tableName, String linkColumn, String selectColumn, String posColumn) static StringgetLikePattern(String substring, String mode) static StringgetLikePatternEnd(String substring) static StringgetLikePatternStart(String substring) static StringgetLikePatternSub(String substring) protected StringgetMySQLLimit(Page page) protected StringgetPeriodSql(Period period, String fieldName) protected intprotected intsetPeriodParamValue(Period period, PreparedStatement ps, int index) protected voidsetRecordCount(Page page, PreparedStatement ps) protected voidprotected <T extends Id>
voidupdate(T record, CommonDAO.RecordUpdater<T> updater) voidupdateColumn(String tableName, int id, String columnName, String value) protected voidprotected voidupdateIds(String tableName, String linkColumn, String valueColumn, String posColumn, int id, List<Integer> values)
-
Field Details
-
SQL_SELECT
- See Also:
-
SQL_SELECT_ALL_FROM
- See Also:
-
SQL_SELECT_COUNT_ROWS
- See Also:
-
SQL_INSERT_IGNORE
- See Also:
-
SQL_INSERT
- See Also:
-
SQL_SET
- See Also:
-
SQL_UPDATE
- See Also:
-
SQL_DELETE
- See Also:
-
SQL_FROM
- See Also:
-
SQL_LEFT_JOIN
- See Also:
-
SQL_LEFT_OUTER_JOIN
- See Also:
-
SQL_INNER_JOIN
- See Also:
-
SQL_WHERE
- See Also:
-
SQL_ORDER_BY
- See Also:
-
SQL_GROUP_BY
- See Also:
-
SQL_AND
- See Also:
-
SQL_OR
- See Also:
-
SQL_LIMIT
- See Also:
-
SQL_DESC
- See Also:
-
SQL_REPLACE
- See Also:
-
SQL_ON_DUP_KEY_UPDATE
- See Also:
-
dateFormat_DDMMYYYY
-
dateFormat_DDMMYYYY_HHMM
-
log
protected ru.bgcrm.logging.Logger log -
con
-
-
Constructor Details
-
CommonDAO
-
-
Method Details
-
lastInsertId
- Throws:
SQLException
-
getFoundRows
- Throws:
SQLException
-
getFoundRows
- Throws:
SQLException
-
getLikePattern
-
getLikePatternSub
-
getLikePatternStart
-
getLikePatternEnd
-
getMySQLLimit
-
setRecordCount
- Throws:
SQLException
-
getPeriodSql
-
setPeriodParamValue
protected int setPeriodParamValue(Period period, PreparedStatement ps, int index) throws SQLException - Throws:
SQLException
-
getIds
protected Set<Integer> getIds(String tableName, String linkColumn, String selectColumn, int id) throws BGException - Throws:
BGException
-
getIds
protected List<Integer> getIds(String tableName, String linkColumn, String selectColumn, String posColumn, int id) throws BGException - Throws:
BGException
-
getGroupedIds
protected Map<Integer,Set<Integer>> getGroupedIds(String tableName, String linkColumn, String selectColumn) throws BGException - Throws:
BGException
-
getGroupedIds
protected Map<Integer,List<Integer>> getGroupedIds(String tableName, String linkColumn, String selectColumn, String posColumn) throws BGException - Throws:
BGException
-
getById
protected <T> T getById(String tableName, int id, CommonDAO.ObjectExtractor<T> extractor) throws BGException - Throws:
BGException
-
deleteById
- Throws:
BGException
-
update
protected <T extends Id> void update(T record, CommonDAO.RecordUpdater<T> updater) throws BGException - Throws:
BGException
-
updateIds
protected void updateIds(String tableName, String linkColumn, String valueColumn, Object id, Set<Integer> values) throws BGException - Throws:
BGException
-
updateIds
protected void updateIds(String tableName, String linkColumn, String valueColumn, String posColumn, int id, List<Integer> values) throws BGException - Throws:
BGException
-
updateColumn
public void updateColumn(String tableName, int id, String columnName, String value) throws BGException - Throws:
BGException
-
sqlToBgException
- Throws:
BGException
-
execute
protected <T> SearchResult<T> execute(SearchResult<T> result, String query, ThrowableConsumer<PreparedStatement, SQLException> prepare, ThrowableFunction<ResultSet, throws BGExceptionCollection<T>, SQLException> builder) - Throws:
BGException
-
execute
protected <T> T execute(String query, ThrowableConsumer<PreparedStatement, SQLException> prepare, ThrowableFunction<ResultSet, throws BGExceptionT, SQLException> builder) - Throws:
BGException
-
execute
protected <T> T execute(String query, ThrowableFunction<ResultSet, T, throws BGExceptionSQLException> builder) - Throws:
BGException
-
executeUpdate
protected int executeUpdate(String query, ThrowableConsumer<PreparedStatement, SQLException> prepare) throws BGException- Throws:
BGException
-
executeBatch
protected int[] executeBatch(String query, ThrowableConsumer<PreparedStatement, SQLException> preparer) throws BGException- Throws:
BGException
-
executeInsert
protected int executeInsert(String query, ThrowableConsumer<PreparedStatement, SQLException> prepare) throws BGException- Throws:
BGException
-
buildPlaceholders
-