Class AbstractRDBMSAction
java.lang.Object
com.kingsrook.qqq.backend.module.rdbms.actions.AbstractRDBMSAction
- Direct Known Subclasses:
RDBMSAggregateAction
,RDBMSCountAction
,RDBMSDeleteAction
,RDBMSInsertAction
,RDBMSQueryAction
,RDBMSUpdateAction
Base class for all core actions in the RDBMS module.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected QueryStat
protected PreparedStatement
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected QQueryFilter
clonedOrNewFilter
(QQueryFilter filter) Either clone the input filter (so we can change it safely), or return a new blank filter.protected void
protected boolean
method that looks at security lock joins, and if a one-to-many is found where the specified field name is on the 'right side' of the join, then a distinct needs added to select clause.protected String
protected RDBMSActionStrategyInterface
protected String
getColumnName
(QFieldMetaData field) Get the column name to use for a field in the RDBMS, from the fieldMetaData.static Connection
getConnection
(AbstractTableActionInput tableActionInput) Get a database connection, per the backend in the request.protected Serializable
getFieldValueFromResultSet
(QFieldMetaData qFieldMetaData, ResultSet resultSet, int i) protected Serializable
getFieldValueFromResultSet
(QFieldType type, ResultSet resultSet, int i) Getter for queryStatprotected String
getSingleGroupByClause
(GroupBy groupBy, JoinsContext joinsContext) protected String
getTableName
(QTableMetaData table) Get the table name to use in the RDBMS from a QTableMetaData.protected void
logSQL
(CharSequence sql, List<?> params, Long mark) protected String
makeFromClause
(QInstance instance, String tableName, JoinsContext joinsContext, List<Serializable> params) protected String
makeOrderByClause
(QTableMetaData table, List<QFilterOrderBy> orderBys, JoinsContext joinsContext) protected String
makeWhereClause
(JoinsContext joinsContext, QQueryFilter filter, List<Serializable> params) Method to make a full WHERE clause.protected Serializable
scrubValue
(QFieldMetaData field, Serializable value) Handle obvious problems with values - like empty string for integer should be null, and type conversions that we can do "better" than jdbc...protected void
setBackendMetaData
(QBackendMetaData backendMetaData) Setter for backendMetaDatastatic void
setLogSQL
(boolean on) Make it easy (e.g., for tests) to turn on logging of SQLstatic void
Make it easy (e.g., for tests) to turn on logging of SQLstatic void
setLogSQLOutput
(String loggerOrSystemOut) Make it easy (e.g., for tests) to turn on logging of SQLstatic void
setLogSQLReformat
(boolean doReformat) Make it easy (e.g., for tests) to turn on poor-man's formatting of SQLvoid
setQueryStat
(QueryStat queryStat) Setter for queryStatprotected void
setSqlAndJoinsInQueryStat
(CharSequence sql, JoinsContext joinsContext) protected void
setValueIfTableHasField
(QRecord record, QTableMetaData table, String fieldName, Serializable value) If the table has a field with the given name, then set the given value in the given record.
-
Field Details
-
queryStat
-
statement
-
isCancelled
protected boolean isCancelled
-
-
Constructor Details
-
AbstractRDBMSAction
public AbstractRDBMSAction()
-
-
Method Details
-
getTableName
Get the table name to use in the RDBMS from a QTableMetaData. That is, table.backendDetails.tableName if set -- else, table.name -
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 -
getConnection
public static Connection getConnection(AbstractTableActionInput tableActionInput) throws SQLException Get a database connection, per the backend in the request. Note that it may be a connection to a read-only backend, per query-hints, and backend settings.- Throws:
SQLException
-
scrubValue
Handle obvious problems with values - like empty string for integer should be null, and type conversions that we can do "better" than jdbc... -
setValueIfTableHasField
protected void setValueIfTableHasField(QRecord record, QTableMetaData table, String fieldName, Serializable value) If the table has a field with the given name, then set the given value in the given record. -
makeFromClause
protected String makeFromClause(QInstance instance, String tableName, JoinsContext joinsContext, List<Serializable> params) -
makeWhereClause
protected String makeWhereClause(JoinsContext joinsContext, QQueryFilter filter, List<Serializable> params) throws IllegalArgumentException Method to make a full WHERE clause. Note that criteria for security are assumed to have been added to the filter during the construction of the JoinsContext.- Throws:
IllegalArgumentException
-
escapeIdentifier
-
getFieldValueFromResultSet
protected Serializable getFieldValueFromResultSet(QFieldType type, ResultSet resultSet, int i) throws SQLException - Throws:
SQLException
-
getFieldValueFromResultSet
protected Serializable getFieldValueFromResultSet(QFieldMetaData qFieldMetaData, ResultSet resultSet, int i) throws SQLException - Throws:
SQLException
-
makeOrderByClause
protected String makeOrderByClause(QTableMetaData table, List<QFilterOrderBy> orderBys, JoinsContext joinsContext) -
getSingleGroupByClause
-
setLogSQL
Make it easy (e.g., for tests) to turn on logging of SQL -
setLogSQL
public static void setLogSQL(boolean on) Make it easy (e.g., for tests) to turn on logging of SQL -
setLogSQLOutput
Make it easy (e.g., for tests) to turn on logging of SQL -
setLogSQLReformat
public static void setLogSQLReformat(boolean doReformat) Make it easy (e.g., for tests) to turn on poor-man's formatting of SQL -
logSQL
-
doesSelectClauseRequireDistinct
method that looks at security lock joins, and if a one-to-many is found where the specified field name is on the 'right side' of the join, then a distinct needs added to select clause. Memoized because it's a lot of gyrations, and it never ever changes for a running server. -
setSqlAndJoinsInQueryStat
-
getQueryStat
Getter for queryStat -
setQueryStat
Setter for queryStat -
doCancelQuery
protected void doCancelQuery() -
clonedOrNewFilter
Either clone the input filter (so we can change it safely), or return a new blank filter. -
setBackendMetaData
Setter for backendMetaData -
getActionStrategy
-