Package ru.bgcrm.dao
Class CommonDAO
java.lang.Object
ru.bgcrm.dao.CommonDAO
- Direct Known Subclasses:
AddressDAO
,BGBillingDAO
,CalendarYearDAO
,Cleaner
,CommonLinkDAO
,ConfigDAO
,ContractCustomerDAO
,CounterDAO
,CustomerDAO
,CustomerGroupDAO
,DatabaseDAO
,DispatchDAO
,DocumentDAO
,EMailDAO
,EntityLogDAO
,FileDataDAO
,IfaceStateDAO
,InvoiceNumberDAO
,InvoiceSearchDAO
,MessageDAO
,MobileDAO
,NewsDAO
,ObjectLogDAO
,ParamDAO
,ParamGroupDAO
,ParamLogDAO
,ParamValueDAO
,ParamValueSearchDAO
,PartyDAO
,PatternDAO
,PeriodicDAO
,ProcessDAO
,ProcessTypeDAO
,PropertiesDAO
,QueryDAO
,QueueDAO
,ReportActionBase.Selector
,ReportDAO
,SavedFilterDAO
,SearchDAO
,SecretDAO
,ShiftDAO
,StatusChangeDAO
,StatusDAO
,SubscriptionDAO
,TabelDAO
,TaskDAO
,TimeBalanceDAO
,UserDAO
,UserGroupDAO
,WorkTaskDAO
,WorkTypeDAO
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interface
protected class
CommonDAO.RecordUpdater<T extends Id>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connection
protected final Log
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
deleteById
(String tableName, int id) protected int
SelectsFOUND_ROWS()
for given statement.protected <T> T
getById
(String tableName, int id, CommonDAO.ObjectExtractor<T> extractor) protected int
Deprecated.getGroupedIds
(String tableName, String linkColumn, String selectColumn) getGroupedIds
(String tableName, String linkColumn, String selectColumn, String posColumn) Queries int list SELECTselectColumn
FROMtableName
WHERElinkColumn
=id
ORDER BYposColumn
static final String
getLikePattern
(String substring, String mode) Deprecated.static final String
getLikePatternEnd
(String substring) Returns SQL LIKE pattern "%" +static final String
getLikePatternStart
(String substring) Returns SQL LIKE pattern + "%"static final String
getLikePatternSub
(String substring) Returns SQL LIKE pattern "%" + + "%"protected String
getPageLimit
(Page page) Generates pageLIMIT offset, rows
query.protected String
getPeriodSql
(Period period, String fieldName) protected int
Takes last generated key fromps
.protected int
setPeriodParamValue
(Period period, PreparedStatement ps, int index) protected void
setRecordCount
(Page page, PreparedStatement ps) protected void
protected <T extends Id>
voidupdate
(T record, CommonDAO.RecordUpdater<T> updater) void
updateColumn
(String tableName, int id, String columnName, String value) protected void
protected void
updateIds
(String tableName, String linkColumn, String valueColumn, String posColumn, int id, List<Integer> values) protected void
updateOrInsert
(String updatePsQuery, String insertPsQuery, Object... params) Updates and if no
-
Field Details
-
log
-
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_VALUES
- See Also:
-
SQL_SET
- See Also:
-
SQL_UPDATE
- See Also:
-
SQL_DELETE
- See Also:
-
SQL_FROM
- See Also:
-
SQL_LEFT_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_LIMIT
- See Also:
-
SQL_DESC
- See Also:
-
SQL_REPLACE
- See Also:
-
SQL_ON_DUP_KEY_UPDATE
- See Also:
-
con
-
-
Constructor Details
-
CommonDAO
protected CommonDAO() -
CommonDAO
-
-
Method Details
-
lastInsertId
Takes last generated key fromps
.- Parameters:
ps
-- Returns:
- Throws:
SQLException
-
getFoundRows
Deprecated.- Throws:
SQLException
-
foundRows
SelectsFOUND_ROWS()
for given statement.- Parameters:
st
-- Returns:
- Throws:
SQLException
-
getLikePattern
Deprecated.Will be changed to private later, usegetLikePatternEnd(String)
,getLikePatternStart(String)
,getLikePatternSub(String)
instead. -
getLikePatternSub
Returns SQL LIKE pattern "%" + + "%"- Parameters:
substring
-- Returns:
-
getLikePatternStart
Returns SQL LIKE pattern + "%"- Parameters:
substring
-- Returns:
-
getLikePatternEnd
Returns SQL LIKE pattern "%" +- Parameters:
substring
-- Returns:
-
updateOrInsert
protected void updateOrInsert(String updatePsQuery, String insertPsQuery, Object... params) throws SQLException Updates and if no- Parameters:
updatePsQuery
- UPDATE query with ? placeholders.insertPsQuery
- INSERT query with ? placeholders.params
-PreparedQuery
parameters for both queries.- Throws:
SQLException
-
getPageLimit
Generates pageLIMIT offset, rows
query.- Parameters:
page
- page instance.- Returns:
-
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 SQLException - Throws:
SQLException
-
getIds
protected List<Integer> getIds(String tableName, String linkColumn, String selectColumn, String posColumn, int id) throws SQLException Queries int list SELECTselectColumn
FROMtableName
WHERElinkColumn
=id
ORDER BYposColumn
- Parameters:
tableName
-linkColumn
-selectColumn
-posColumn
-id
-- Returns:
- Throws:
SQLException
-
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 SQLException - Throws:
SQLException
-
updateIds
protected void updateIds(String tableName, String linkColumn, String valueColumn, String posColumn, int id, List<Integer> values) throws SQLException - Throws:
SQLException
-
updateColumn
public void updateColumn(String tableName, int id, String columnName, String value) throws SQLException - Throws:
SQLException
-
sqlToBgException
- Throws:
BGMessageException
BGException
-