Class BaseRDBMSActionStrategy
java.lang.Object
com.kingsrook.qqq.backend.module.rdbms.strategy.BaseRDBMSActionStrategy
- All Implemented Interfaces:
RDBMSActionStrategyInterface
- Direct Known Subclasses:
MySQLFullTextIndexFieldStrategy,PostgreSQLRDBMSActionStrategy,SQLiteRDBMSActionStrategy
Note that much of this class came from the old (old) QueryManager class.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.kingsrook.qqq.backend.module.rdbms.strategy.RDBMSActionStrategyInterface
RDBMSActionStrategyInterface.ResultSetProcessor -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendCriterionToWhereClause(QFilterCriteria criterion, StringBuilder clause, String column, List<Serializable> values, QFieldMetaData field) modifies the clause StringBuilder (appending to it) returning the number of expected number of params to bindbeginConsistentRead(Connection connection, ConsistentReadInput input) MySQL/MariaDB (InnoDB): START TRANSACTION WITH CONSISTENT SNAPSHOT (READ ONLY).protected voidbindParam(PreparedStatement statement, int index, byte[] value) protected voidbindParam(PreparedStatement statement, int index, Boolean value) protected voidbindParam(PreparedStatement statement, int index, Double value) protected voidbindParam(PreparedStatement statement, int index, Integer value) protected voidbindParam(PreparedStatement statement, int index, Long value) protected voidbindParam(PreparedStatement statement, int index, String value) protected voidbindParam(PreparedStatement statement, int index, BigDecimal value) protected voidbindParam(PreparedStatement statement, int index, Date value) protected voidbindParam(PreparedStatement statement, int index, Timestamp value) protected voidbindParam(PreparedStatement statement, int index, LocalDate value) protected voidbindParam(PreparedStatement statement, int index, LocalDateTime value) protected voidbindParam(PreparedStatement statement, int index, Calendar value) protected voidbindParamNull(PreparedStatement statement, int index) protected intbindParamObject(PreparedStatement statement, int index, Object value) index is 1-based!!protected voidbindParams(Object[] params, PreparedStatement statement) voidexecuteBatchUpdate(Connection connection, String updateSQL, List<List<Serializable>> values) executeInsertForGeneratedIds(Connection connection, String sql, List<Object> params, QFieldMetaData primaryKeyField) voidexecuteStatement(PreparedStatement statement, CharSequence sql, RDBMSActionStrategyInterface.ResultSetProcessor processor, Object... params) executeUpdate(Connection connection, String sql, List<Object> params) executeUpdateForRowCount(Connection connection, String sql, Object... params) getAggregateExpression(AggregateOperator operator, String column, String otherColumn, Aggregate aggregate, RDBMSBackendMetaData backend, List<Serializable> params) ANSI aggregate functions used by H2 and MySQL where supported.protected StringgetBucketTimeZone(ZoneId zone) SQL offset parameters use ISO signs and an explicit zero offset instead of Z.protected StringgetColumnName(QFieldMetaData field) Get the column name to use for a field in the RDBMS, from the fieldMetaData.getFieldValueFromResultSet(QFieldType type, ResultSet resultSet, int i) getGroupByBucketExpression(GroupBy group, String column, QFieldType sourceType, RDBMSBackendMetaData backend, List<Serializable> params) Equal-width bins with max included in the last bin, and session-local date buckets.getPageSize(AbstractActionInput actionInput) getSampledTableExpression(String table, String alias, BigDecimal percent, List<Serializable> params) Sample the main relation before joining.Getter for statisticsH2 supports ordered-set aggregates; MySQL supports the remaining extensions.protected voidincrementStatistic(String statName) Increment a statisticprotected booleanisH2(RDBMSBackendMetaData backend) Use explicit backend metadata to identify H2.protected PreparedStatementprepareStatementAndBindParams(Connection connection, String sql, Object[] params) voidclear the map of statisticsvoidsetCollectStatistics(boolean collectStatistics) Setter for collectStatisticsvoidsetPageSize(int pageSize) Setter for pageSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.kingsrook.qqq.backend.module.rdbms.strategy.RDBMSActionStrategyInterface
configureStatementForLargeResults, getIdentifierQuoteString, getInsertDefaultValuesClause, jsonMergeAssignment, jsonObjectPlaceholder, jsonPathExpression, jsonPathPredicate, supportsForUpdateSkipLocked
-
Field Details
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE- See Also:
-
PAGE_SIZE
public static int PAGE_SIZE -
STAT_QUERIES_RAN
- See Also:
-
STAT_BATCHES_RAN
- See Also:
-
-
Constructor Details
-
BaseRDBMSActionStrategy
public BaseRDBMSActionStrategy()
-
-
Method Details
-
appendCriterionToWhereClause
public Integer appendCriterionToWhereClause(QFilterCriteria criterion, StringBuilder clause, String column, List<Serializable> values, QFieldMetaData field) Description copied from interface:RDBMSActionStrategyInterfacemodifies the clause StringBuilder (appending to it) returning the number of expected number of params to bind- Specified by:
appendCriterionToWhereClausein interfaceRDBMSActionStrategyInterface
-
getFieldValueFromResultSet
public Serializable getFieldValueFromResultSet(QFieldType type, ResultSet resultSet, int i) throws SQLException - Specified by:
getFieldValueFromResultSetin interfaceRDBMSActionStrategyInterface- Throws:
SQLException
-
executeUpdate
public PreparedStatement executeUpdate(Connection connection, String sql, List<Object> params) throws SQLException - Specified by:
executeUpdatein interfaceRDBMSActionStrategyInterface- Throws:
SQLException
-
executeBatchUpdate
public void executeBatchUpdate(Connection connection, String updateSQL, List<List<Serializable>> values) throws SQLException - Specified by:
executeBatchUpdatein interfaceRDBMSActionStrategyInterface- Throws:
SQLException
-
executeInsertForGeneratedIds
public List<Serializable> executeInsertForGeneratedIds(Connection connection, String sql, List<Object> params, QFieldMetaData primaryKeyField) throws SQLException - Specified by:
executeInsertForGeneratedIdsin interfaceRDBMSActionStrategyInterface- Throws:
SQLException
-
executeUpdateForRowCount
public Integer executeUpdateForRowCount(Connection connection, String sql, Object... params) throws SQLException - Specified by:
executeUpdateForRowCountin interfaceRDBMSActionStrategyInterface- Throws:
SQLException
-
executeStatement
public void executeStatement(PreparedStatement statement, CharSequence sql, RDBMSActionStrategyInterface.ResultSetProcessor processor, Object... params) throws SQLException, QException - Specified by:
executeStatementin interfaceRDBMSActionStrategyInterface- Throws:
SQLExceptionQException
-
getPageSize
- Specified by:
getPageSizein interfaceRDBMSActionStrategyInterface
-
prepareStatementAndBindParams
protected PreparedStatement prepareStatementAndBindParams(Connection connection, String sql, Object[] params) throws SQLException - Throws:
SQLException
-
bindParams
- Throws:
SQLException
-
bindParamObject
protected int bindParamObject(PreparedStatement statement, int index, Object value) throws SQLException index is 1-based!!- Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParam
protected void bindParam(PreparedStatement statement, int index, Timestamp value) throws SQLException - Throws:
SQLException
-
bindParam
protected void bindParam(PreparedStatement statement, int index, Calendar value) throws SQLException - Throws:
SQLException
-
bindParam
protected void bindParam(PreparedStatement statement, int index, LocalDate value) throws SQLException - Throws:
SQLException
-
bindParam
protected void bindParam(PreparedStatement statement, int index, LocalDateTime value) throws SQLException - Throws:
SQLException
-
bindParam
protected void bindParam(PreparedStatement statement, int index, BigDecimal value) throws SQLException - Throws:
SQLException
-
bindParam
- Throws:
SQLException
-
bindParamNull
- Throws:
SQLException
-
incrementStatistic
Increment a statistic -
setCollectStatistics
public void setCollectStatistics(boolean collectStatistics) Setter for collectStatistics -
resetStatistics
public void resetStatistics()clear the map of statistics -
getStatistics
-
setPageSize
public void setPageSize(int pageSize) Setter for pageSize -
getColumnName
Get the column name to use for a field in the RDBMS, from the fieldMetaData. That is, field.backendName if set -- else, field.name -
beginConsistentRead
public ConsistentReadStart beginConsistentRead(Connection connection, ConsistentReadInput input) throws SQLException MySQL/MariaDB (InnoDB): START TRANSACTION WITH CONSISTENT SNAPSHOT (READ ONLY). Tables on other engines (e.g., MyISAM) aren't covered by the snapshot, and are reported as BEST_EFFORT. H2: REPEATABLE READ (MVCC), pinned by a first read. Other databases: as the interface default.- Specified by:
beginConsistentReadin interfaceRDBMSActionStrategyInterface- Throws:
SQLException
-
getSupportedAggregateCapabilities
H2 supports ordered-set aggregates; MySQL supports the remaining extensions.- Specified by:
getSupportedAggregateCapabilitiesin interfaceRDBMSActionStrategyInterface
-
getBucketTimeZone
-
isH2
Use explicit backend metadata to identify H2. -
getAggregateExpression
public String getAggregateExpression(AggregateOperator operator, String column, String otherColumn, Aggregate aggregate, RDBMSBackendMetaData backend, List<Serializable> params) ANSI aggregate functions used by H2 and MySQL where supported.- Specified by:
getAggregateExpressionin interfaceRDBMSActionStrategyInterface
-
getSampledTableExpression
public String getSampledTableExpression(String table, String alias, BigDecimal percent, List<Serializable> params) Sample the main relation before joining. RAND is supported by H2 and MySQL.- Specified by:
getSampledTableExpressionin interfaceRDBMSActionStrategyInterface
-
getGroupByBucketExpression
public String getGroupByBucketExpression(GroupBy group, String column, QFieldType sourceType, RDBMSBackendMetaData backend, List<Serializable> params) Equal-width bins with max included in the last bin, and session-local date buckets.- Specified by:
getGroupByBucketExpressionin interfaceRDBMSActionStrategyInterface
-