Package ru.bgcrm.dao
Class CommonDAO
java.lang.Object
ru.bgcrm.dao.CommonDAO
- Direct Known Subclasses:
AddressDAO,BGBillingDAO,Cleaner,CommonLinkDAO,ConfigDAO,ContractCustomerDAO,CustomerDAO,CustomerGroupDAO,CustomerParamSearchDAO,DatabaseDAO,DemoDAO,DispatchDAO,DocumentDAO,EMailDAO,EntityLogDAO,ExecuteSQL,FileDataDAO,Filter,GrplDAO,IfaceStateDAO,InvoiceNumberDAO,InvoiceSearchDAO,MessageDAO,MessagePossibleProcessSearch,MobileDAO,NewsDAO,OldParamSearchDAO,ParamDAO,ParamGroupDAO,ParamLogDAO,ParamValueDAO,ParamValueSelect,PartyDAO,PatternDAO,PeriodicDAO,ProcessCloneDAO,ProcessDAO,ProcessLinkSearchDAO,ProcessParamSearchDAO,ProcessSearchDAO,ProcessTypeDAO,PropertiesDAO,QueryDAO,QueryHistoryDAO,QueueDAO,ReportActionBase.Selector,SavedFilterDAO,SearchDAO,SecretDAO,ShiftDAO,StatusChangeDAO,StatusDAO,SubscriptionDAO,TabelDAO,TaskDAO,UserDAO,UserGroupDAO,WorkTaskDAO,WorkTypeDAO
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceprotected classCommonDAO.RecordUpdater<T extends Id> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connectionprotected final Logprotected 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 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 voiddeleteById(String tableName, int id) static intSelectsFOUND_ROWS()for given statement.protected <T> TgetById(String tableName, int id, CommonDAO.ObjectExtractor<T> extractor) getGroupedIds(String tableName, String linkColumn, String selectColumn) getGroupedIds(String tableName, String linkColumn, String selectColumn, String posColumn) Queries int list SELECTselectColumnFROMtableNameWHERElinkColumn=idORDER BYposColumnprotected StringgetPageLimit(Page page) Deprecated.protected StringgetPeriodSql(Period period, String fieldName) Deprecated.protected intTakes last generated key fromps.protected intsetPeriodParamValue(Period period, PreparedStatement ps, int index) Deprecated.protected voidsetRecordCount(Page page, PreparedStatement ps) Deprecated.protected <T extends Id>
voidupdate(T record, CommonDAO.RecordUpdater<T> updater) protected 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) protected intupdateOrInsert(String updatePsQuery, String insertPsQuery, Object... params) Updates and if no records updated then inserting a new one.
-
Field Details
-
log
-
SQL_SELECT
- See Also:
-
SQL_SELECT_ALL_FROM
- See Also:
-
SQL_SELECT_COUNT_ROWS
- See Also:
-
SQL_DISTINCT
- See Also:
-
SQL_INSERT_IGNORE_INTO
- See Also:
-
SQL_INSERT_INTO
- See Also:
-
SQL_VALUES
- See Also:
-
SQL_VALUES_1
- See Also:
-
SQL_VALUES_2
- See Also:
-
SQL_VALUES_3
- See Also:
-
SQL_VALUES_4
- See Also:
-
SQL_VALUES_5
- See Also:
-
SQL_SET
- See Also:
-
SQL_UPDATE
- See Also:
-
SQL_DELETE
- See Also:
-
SQL_DELETE_FROM
- 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:
-
SQL_UNION_ALL
- See Also:
-
con
-
-
Constructor Details
-
CommonDAO
protected CommonDAO() -
CommonDAO
-
-
Method Details
-
foundRows
SelectsFOUND_ROWS()for given statement.- Parameters:
st-- Returns:
- Throws:
SQLException
-
lastInsertId
Takes last generated key fromps.- Parameters:
ps-- Returns:
- Throws:
SQLException
-
updateOrInsert
protected int updateOrInsert(String updatePsQuery, String insertPsQuery, Object... params) throws SQLException Updates and if no records updated then inserting a new one.- Parameters:
updatePsQuery- UPDATE query with ? placeholders.insertPsQuery- INSERT query with ? placeholders.params-PreparedQueryparameters for both queries.- Returns:
- ID of a newly inserted record, or
0 - 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 SELECTselectColumnFROMtableNameWHERElinkColumn=idORDER BYposColumn- Parameters:
tableName-linkColumn-selectColumn-posColumn-id-- Returns:
- Throws:
SQLException
-
getGroupedIds
protected Map<Integer,Set<Integer>> getGroupedIds(String tableName, String linkColumn, String selectColumn) throws SQLException - Throws:
SQLException
-
getGroupedIds
protected Map<Integer,List<Integer>> getGroupedIds(String tableName, String linkColumn, String selectColumn, String posColumn) throws SQLException - Throws:
SQLException
-
getById
protected <T> T getById(String tableName, int id, CommonDAO.ObjectExtractor<T> extractor) throws SQLException - Throws:
SQLException
-
deleteById
- Throws:
SQLException
-
update
protected <T extends Id> void update(T record, CommonDAO.RecordUpdater<T> updater) throws SQLException - Throws:
SQLException
-
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
protected void updateColumn(String tableName, int id, String columnName, String value) throws SQLException - Throws:
SQLException
-
getPageLimit
Deprecated. -
setRecordCount
Deprecated.- Throws:
SQLException
-
getPeriodSql
Deprecated. -
setPeriodParamValue
@Deprecated protected int setPeriodParamValue(Period period, PreparedStatement ps, int index) throws SQLException Deprecated.- Throws:
SQLException
-