Class PostgreSQLRDBMSActionStrategy
java.lang.Object
com.kingsrook.qqq.backend.module.rdbms.strategy.BaseRDBMSActionStrategy
com.kingsrook.qqq.backend.module.postgres.strategy.PostgreSQLRDBMSActionStrategy
- All Implemented Interfaces:
RDBMSActionStrategyInterface
PostgreSQL specialization of the default RDBMS/JDBC action strategy.
This class provides PostgreSQL-specific implementations for database operations,
including optimized insert operations using RETURNING clause, proper handling
of temporal data types, and PostgreSQL-specific parameter binding behavior.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.kingsrook.qqq.backend.module.rdbms.strategy.RDBMSActionStrategyInterface
RDBMSActionStrategyInterface.ResultSetProcessor -
Field Summary
Fields inherited from class com.kingsrook.qqq.backend.module.rdbms.strategy.BaseRDBMSActionStrategy
DEFAULT_PAGE_SIZE, PAGE_SIZE, STAT_BATCHES_RAN, STAT_QUERIES_RAN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbindParam(PreparedStatement statement, int index, Double value) Override bindParam for Double to use Types.OTHER for nulls.protected voidbindParam(PreparedStatement statement, int index, Integer value) Override bindParam for Integer to use Types.OTHER for nulls.protected voidbindParam(PreparedStatement statement, int index, Long value) Override bindParam for Long to use Types.OTHER for nulls.protected voidbindParam(PreparedStatement statement, int index, String value) Override bindParam for String to use Types.OTHER for nulls.protected intbindParamObject(PreparedStatement statement, int index, Object value) Override parameter binding for PostgreSQL-specific handling.executeInsertForGeneratedIds(Connection connection, String sql, List<Object> params, QFieldMetaData primaryKeyField) PostgreSQL uses RETURNING clause for getting generated IDs.PostgreSQL uses double quotes for identifier quoting.Methods inherited from class com.kingsrook.qqq.backend.module.rdbms.strategy.BaseRDBMSActionStrategy
appendCriterionToWhereClause, bindParam, bindParam, bindParam, bindParam, bindParam, bindParam, bindParam, bindParam, bindParamNull, bindParams, executeBatchUpdate, executeStatement, executeUpdate, executeUpdateForRowCount, getColumnName, getFieldValueFromResultSet, getPageSize, getStatistics, incrementStatistic, prepareStatementAndBindParams, resetStatistics, setCollectStatistics, setPageSize
-
Constructor Details
-
PostgreSQLRDBMSActionStrategy
public PostgreSQLRDBMSActionStrategy()
-
-
Method Details
-
executeInsertForGeneratedIds
public List<Serializable> executeInsertForGeneratedIds(Connection connection, String sql, List<Object> params, QFieldMetaData primaryKeyField) throws SQLException PostgreSQL uses RETURNING clause for getting generated IDs. This is more efficient than the default JDBC approach.- Specified by:
executeInsertForGeneratedIdsin interfaceRDBMSActionStrategyInterface- Overrides:
executeInsertForGeneratedIdsin classBaseRDBMSActionStrategy- Parameters:
connection- the database connectionsql- the INSERT SQL statementparams- the query parametersprimaryKeyField- the primary key field metadata- Returns:
- list of generated IDs
- Throws:
SQLException- if a database error occurs
-
bindParamObject
protected int bindParamObject(PreparedStatement statement, int index, Object value) throws SQLException Override parameter binding for PostgreSQL-specific handling. PostgreSQL JDBC driver requires explicit handling of temporal types and is stricter about type matching than other databases. For null values, PostgreSQL needs Types.OTHER (not Types.CHAR) so it can infer the correct type from the column definition.- Overrides:
bindParamObjectin classBaseRDBMSActionStrategy- Parameters:
statement- the prepared statementindex- the parameter indexvalue- the parameter value- Returns:
- the number of parameters bound (always 1)
- Throws:
SQLException- if a database error occurs
-
bindParam
Override bindParam for Integer to use Types.OTHER for nulls. This allows PostgreSQL to properly infer types in all contexts.- Overrides:
bindParamin classBaseRDBMSActionStrategy- Parameters:
statement- the prepared statementindex- the parameter indexvalue- the integer value (may be null)- Throws:
SQLException- if a database error occurs
-
bindParam
Override bindParam for Long to use Types.OTHER for nulls. This allows PostgreSQL to properly infer types in all contexts.- Overrides:
bindParamin classBaseRDBMSActionStrategy- Parameters:
statement- the prepared statementindex- the parameter indexvalue- the long value (may be null)- Throws:
SQLException- if a database error occurs
-
bindParam
Override bindParam for Double to use Types.OTHER for nulls. This allows PostgreSQL to properly infer types in all contexts.- Overrides:
bindParamin classBaseRDBMSActionStrategy- Parameters:
statement- the prepared statementindex- the parameter indexvalue- the double value (may be null)- Throws:
SQLException- if a database error occurs
-
bindParam
Override bindParam for String to use Types.OTHER for nulls. This allows PostgreSQL to properly infer types in all contexts.- Overrides:
bindParamin classBaseRDBMSActionStrategy- Parameters:
statement- the prepared statementindex- the parameter indexvalue- the string value (may be null)- Throws:
SQLException- if a database error occurs
-
getIdentifierQuoteString
PostgreSQL uses double quotes for identifier quoting.- Returns:
- double quote string for identifier quoting
-