Package org.hibernate.dialect
Class PostgresPlusDialect
java.lang.Object
org.hibernate.dialect.Dialect
org.hibernate.dialect.PostgreSQLDialect
org.hibernate.dialect.PostgresPlusDialect
- All Implemented Interfaces:
FunctionContributor
,TypeContributor
,ConversionContext
An SQL dialect for Postgres Plus
-
Nested Class Summary
Nested classes/interfaces inherited from class org.hibernate.dialect.Dialect
Dialect.SizeStrategy, Dialect.SizeStrategyImpl
-
Field Summary
Fields inherited from class org.hibernate.dialect.PostgreSQLDialect
driverKind, MINIMUM_VERSION
Fields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, FALSE_STRING_VALUES, LEGACY_LOB_MERGE_STRATEGY, LOG_BASE2OF10, NEW_LOCATOR_LOB_MERGE_STRATEGY, QUOTE, STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY, TRUE_STRING_VALUES
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PostgresPlusDialectPostgresPlusDialect
(DatabaseVersion version) -
Method Summary
Modifier and TypeMethodDescriptioncastPattern
(CastType from, CastType to) Obtain a pattern for the SQL equivalent to acast()
function call.createOptionalTableUpdateOperation
(EntityMutationTarget mutationTarget, OptionalTableUpdate optionalTableUpdate, SessionFactoryImplementor factory) Create aMutationOperation
for a updating an optional tableTranslation of the HQL/JPQLcurrent_timestamp
function, which maps to the Java typeTimestamp
which is a datetime with no time zone.Get the command used to select a GUID from the database.void
initializeFunctionRegistry
(FunctionContributions functionContributions) Initialize the given registry with any dialect-specific functions.boolean
Return whether the dialect considers an empty string value to be null.int
registerResultSetOutParameter
(CallableStatement statement, int col) Registers a parameter capable of returning aResultSet
by position, either anOUT
parameter, or aREF_CURSOR
parameter as defined in Java 8.timestampdiffPattern
(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) Obtain a pattern for the SQL equivalent to atimestampdiff()
function call.Methods inherited from class org.hibernate.dialect.PostgreSQLDialect
addSqlHintOrComment, appendBinaryLiteral, appendBooleanValueString, appendDatetimeFormat, appendDateTimeLiteral, appendDateTimeLiteral, appendDateTimeLiteral, augmentRecognizedTableTypes, buildIdentifierHelper, buildSQLExceptionConversionDelegate, canBatchTruncate, castType, columnType, contributePostgreSQLTypes, contributeTypes, currentTime, currentTimestampWithTimeZone, datetimeFormat, extractPattern, getAggregateSupport, getAlterColumnTypeString, getBeforeDropStatement, getCallableStatementSupport, getCascadeConstraintsString, getCaseInsensitiveLike, getCreateEnumTypeCommand, getCurrentSchemaCommand, getCurrentTimestampSelectString, getDefaultIntervalSecondScale, getDefaultNonContextualLobCreation, getDefaultOrdinalityColumnName, getDefaultStatementBatchSize, getDmlTargetColumnQualifierSupport, getDropEnumTypeCommand, getEnumTypeDeclaration, getFallbackSqmInsertStrategy, getFallbackSqmMutationStrategy, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateSkipLockedString, getForUpdateSkipLockedString, getForUpdateString, getForUpdateString, getFractionalSecondPrecisionInNanos, getFunctionalDependencyAnalysisSupport, getGroupBySelectItemReferenceStrategy, getIdentityColumnSupport, getLimitHandler, getMaxIdentifierLength, getMaxVarbinaryLength, getMaxVarcharCapacity, getMaxVarcharLength, getMinimumSupportedVersion, getNameQualifierSupport, getNationalizationSupport, getNativeParameterMarkerStrategy, getNativeValueGenerationStrategy, getNoColumnsInsertString, getQueryHintString, getQuerySequencesString, getReadLockString, getReadLockString, getResultSet, getResultSet, getResultSet, getSelectClauseNullString, getSequenceSupport, getTableExporter, getTimeZoneSupport, getUniqueDelegate, getViolatedConstraintNameExtractor, getWriteLockString, getWriteLockString, getWriteRowLockStrategy, isCurrentTimestampSelectStringCallable, qualifyIndexName, quoteCollation, registerColumnTypes, requiresParensForTupleDistinctCounts, resolveSqlTypeCode, resolveSqlTypeDescriptor, rowId, rowIdSqlType, supportsAlterColumnType, supportsBindingNullSqlTypeForSetNull, supportsCaseInsensitiveLike, supportsCommentOn, supportsConflictClauseForInsertCTE, supportsCurrentTimestampSelection, supportsDistinctFromPredicate, supportsFetchClause, supportsFromClauseInUpdate, supportsIfExistsAfterAlterTable, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTableName, supportsIfExistsBeforeTypeName, supportsInsertReturning, supportsIsTrue, supportsJdbcConnectionLobCreation, supportsLateral, supportsLobValueChangePropagation, supportsMaterializedLobAccess, supportsMinMaxOnUuid, supportsNonQueryWithCTE, supportsNoWait, supportsOffsetInSubquery, supportsOuterJoinForUpdate, supportsPartitionBy, supportsRecursiveCTE, supportsSkipLocked, supportsStandardArrays, supportsTemporalLiteralOffset, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsValuesList, supportsWait, supportsWindowFunctions, timestampaddPattern, translateExtractField, useConnectionToCreateLob, useInputStreamToInsertBlob
Methods inherited from class org.hibernate.dialect.Dialect
addQueryHints, appendArrayLiteral, appendCheckConstraintOptions, appendIntervalLiteral, appendIntervalLiteral, appendLiteral, appendLockHint, appendUUIDLiteral, applyLocksToSql, augmentPhysicalTableTypes, buildStringToBooleanCast, buildStringToBooleanCastDecode, buildStringToBooleanDecode, canCreateCatalog, canCreateSchema, canDisableConstraints, checkVersion, closeQuote, contribute, contributeFunctions, currentDate, currentLocalTime, currentLocalTimestamp, defaultScrollMode, determineDatabaseVersion, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, doesRoundTemporalOnOverflow, dropConstraints, equivalentTypes, escapeComment, forceLobAsLastValue, generatedAs, getAddColumnString, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAlterTableString, getArrayTypeName, getAuxiliaryDatabaseObjectExporter, getBatchLoadSizingStrategy, getCheckCondition, getCheckCondition, getCheckCondition, getCheckCondition, getCheckCondition, getCheckCondition, getCheckConstraintString, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateEnumTypeCommand, getCreateIndexString, getCreateIndexTail, getCreateMultisetTableString, getCreateSchemaCommand, getCreateTableString, getCreateTemporaryTableColumnAnnotation, getCreateUserDefinedTypeExtensionsString, getCreateUserDefinedTypeKindString, getCrossReferenceParentTableFilter, getDefaultDecimalPrecision, getDefaultLobLength, getDefaultProperties, getDefaultTimestampPrecision, getDefaultUseGetGeneratedKeys, getDisableConstraintsStatement, getDisableConstraintStatement, getDoublePrecision, getDropCatalogCommand, getDropEnumTypeCommand, getDropForeignKeyString, getDropSchemaCommand, getDropTableString, getDropUniqueKeyString, getDual, getEnableConstraintsStatement, getEnableConstraintStatement, getEnumTypeDeclaration, getFallbackSchemaManagementTool, getFloatPrecision, getForeignKeyExporter, getForUpdateString, getForUpdateString, getForUpdateString, getFromDualForSelectOnly, getHqlTranslator, getIndexExporter, getInExpressionCountLimit, getKeywords, getLobMergeStrategy, getLockingStrategy, getLockRowIdentifier, getLowercaseFunction, getMaxAliasLength, getMaxNVarcharCapacity, getMaxNVarcharLength, getMaxVarbinaryCapacity, getMultiKeyLoadSizingStrategy, getNativeIdentifierGeneratorStrategy, getNullColumnString, getNullColumnString, getNullOrdering, getParameterCountLimit, getPreferredSqlTypeCodeForArray, getPreferredSqlTypeCodeForBoolean, getQueryHintString, getReadRowLockStrategy, getRowIdColumnString, getSchemaNameResolver, getSequenceExporter, getSequenceInformationExtractor, getSizeStrategy, getSqmTranslatorFactory, getSupportedTemporaryTableKind, getTableCleaner, getTableComment, getTableMigrator, getTableTypeString, getTemporaryTableAfterUseAction, getTemporaryTableBeforeUseAction, getTemporaryTableCreateCommand, getTemporaryTableCreateOptions, getTemporaryTableDdlTransactionHandling, getTemporaryTableDropCommand, getTemporaryTableExporter, getTemporaryTableTruncateCommand, getTimeoutInSeconds, getTruncateTableStatement, getTruncateTableStatements, getUniqueKeyExporter, getUserDefinedTypeComment, getUserDefinedTypeExporter, getVersion, hasAlterTable, hasDataTypeBeforeGeneratedAs, hasSelfReferentialForeignKeyBug, initDefaultProperties, isJdbcLogWarningsEnabledByDefault, isLob, openQuote, ordinal, prependComment, quote, registerDefaultKeywords, registerKeyword, registerKeywords, registerResultSetOutParameter, requiresCastForConcatenatingNonStrings, requiresFloatCastingOfIntegerDivision, requiresParensForTupleCounts, resolveSqlTypeCode, resolveSqlTypeLength, stripsTrailingSpacesFromChar, supportsBatchUpdates, supportsBindAsCallableArgument, supportsBindingNullForSetObject, supportsBitType, supportsCascadeDelete, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsFractionalTimestampArithmetic, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsAfterTypeName, supportsInsertReturningGeneratedKeys, supportsInsertReturningRowId, supportsLockTimeouts, supportsNamedParameters, supportsNationalizedMethods, supportsNoColumnsInsert, supportsNullPrecedence, supportsOrderByInSubquery, supportsOrdinalSelectItemReference, supportsPredicateAsExpression, supportsRefCursors, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsStandardCurrentTimestampFunction, supportsSubqueryInSelect, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTableOptions, supportsTemporaryTablePrimaryKey, supportsTemporaryTables, supportsTruncateWithCast, supportsTupleDistinctCounts, supportsUnionAll, supportsUnionInSubquery, supportsUpdateReturning, supportsValuesListForInsert, toBooleanValueString, toQuotedIdentifier, toString, transformSelectString, translateDurationField, trimPattern, unquoteGetGeneratedKeys, useArrayForMultiValuedParameters, useCrossReferenceForeignKeys, useFollowOnLocking, useMaterializedLobWhenCapacityExceeded
-
Constructor Details
-
PostgresPlusDialect
public PostgresPlusDialect()Constructs a PostgresPlusDialect -
PostgresPlusDialect
-
PostgresPlusDialect
-
-
Method Details
-
initializeFunctionRegistry
Description copied from class:Dialect
Initialize the given registry with any dialect-specific functions.Support for certain SQL functions is required, and if the database does not support a required function, then the dialect must define a way to emulate it.
These required functions include the functions defined by the JPA query language specification:
-
avg(arg)
- aggregate function -
count([distinct ]arg)
- aggregate function -
max(arg)
- aggregate function -
min(arg)
- aggregate function -
sum(arg)
- aggregate function
-
coalesce(arg0, arg1, ...)
-
nullif(arg0, arg1)
-
lower(arg)
-
upper(arg)
-
length(arg)
-
concat(arg0, arg1, ...)
-
locate(pattern, string[, start])
-
substring(string, start[, length])
-
trim([[spec ][character ]from] string)
-
abs(arg)
-
mod(arg0, arg1)
-
sqrt(arg)
-
current date
-
current time
-
current timestamp
-
any(arg)
- aggregate function -
every(arg)
- aggregate function
-
var_samp(arg)
- aggregate function -
var_pop(arg)
- aggregate function -
stddev_samp(arg)
- aggregate function -
stddev_pop(arg)
- aggregate function
-
cast(arg as Type)
-
extract(field from arg)
-
ln(arg)
-
exp(arg)
-
power(arg0, arg1)
-
floor(arg)
-
ceiling(arg)
-
position(pattern in string)
-
substring(string from start[ for length])
-
overlay(string placing replacement from start[ for length])
java.time
types:-
local date
-
local time
-
local datetime
-
offset datetime
-
instant
-
left(string, length)
-
right(string, length)
-
replace(string, pattern, replacement)
-
pad(string with length spec[ character])
-
repeat(string, times)
-
pi
-
log10(arg)
-
log(base, arg)
-
sign(arg)
-
sin(arg)
-
cos(arg)
-
tan(arg)
-
asin(arg)
-
acos(arg)
-
atan(arg)
-
atan2(arg0, arg1)
-
round(arg0[, arg1])
-
truncate(arg0[, arg1])
-
sinh(arg)
-
tanh(arg)
-
cosh(arg)
-
least(arg0, arg1, ...)
-
greatest(arg0, arg1, ...)
-
degrees(arg)
-
radians(arg)
-
bitand(arg1, arg1)
-
bitor(arg1, arg1)
-
bitxor(arg1, arg1)
-
format(datetime as pattern)
-
collate(string as collation)
-
str(arg)
- synonym ofcast(a as String)
-
ifnull(arg0, arg1)
- synonym ofcoalesce(a, b)
extract()
, and desugared by the parser:-
second(arg)
- synonym ofextract(second from a)
-
minute(arg)
- synonym ofextract(minute from a)
-
hour(arg)
- synonym ofextract(hour from a)
-
day(arg)
- synonym ofextract(day from a)
-
month(arg)
- synonym ofextract(month from a)
-
year(arg)
- synonym ofextract(year from a)
second()
function returns a floating point value, contrary to the integer type returned by the native function with this name on many databases. Thus, we don't just naively map these HQL functions to the native SQL functions with the same names.- Overrides:
initializeFunctionRegistry
in classPostgreSQLDialect
-
-
castPattern
Description copied from class:Dialect
Obtain a pattern for the SQL equivalent to acast()
function call. The resulting pattern must contain ?1 and ?2 placeholders for the arguments.- Overrides:
castPattern
in classPostgreSQLDialect
- Parameters:
from
- aCastType
indicating the type of the value argumentto
- aCastType
indicating the type the value argument is cast to
-
currentTimestamp
Description copied from class:Dialect
Translation of the HQL/JPQLcurrent_timestamp
function, which maps to the Java typeTimestamp
which is a datetime with no time zone. This contradicts ANSI SQL wherecurrent_timestamp
has the typeTIMESTAMP WITH TIME ZONE
.It is recommended to override this in dialects for databases which support
localtimestamp
ortimestamp at local
.- Overrides:
currentTimestamp
in classPostgreSQLDialect
-
timestampdiffPattern
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) Description copied from class:Dialect
Obtain a pattern for the SQL equivalent to atimestampdiff()
function call. The resulting pattern must contain ?1, ?2, and ?3 placeholders for the arguments.- Overrides:
timestampdiffPattern
in classPostgreSQLDialect
- Parameters:
unit
- the first argumentfromTemporalType
- true if the first argument is a timestamp, false if a datetoTemporalType
- true if the second argument is
-
isEmptyStringTreatedAsNull
public boolean isEmptyStringTreatedAsNull()Description copied from class:Dialect
Return whether the dialect considers an empty string value to be null.- Overrides:
isEmptyStringTreatedAsNull
in classDialect
- Returns:
- boolean True if an empty string is treated as null, false otherwise.
-
registerResultSetOutParameter
Description copied from class:Dialect
Registers a parameter capable of returning aResultSet
by position, either anOUT
parameter, or aREF_CURSOR
parameter as defined in Java 8.- Overrides:
registerResultSetOutParameter
in classPostgreSQLDialect
- Parameters:
statement
- The callable statement.col
- The bind position at which to register the output param.- Returns:
- The number of (contiguous) bind positions used.
- Throws:
SQLException
- Indicates problems registering the param.
-
getSelectGUIDString
Description copied from class:Dialect
Get the command used to select a GUID from the database.Optional operation.
- Overrides:
getSelectGUIDString
in classDialect
- Returns:
- The appropriate command.
-
createOptionalTableUpdateOperation
public MutationOperation createOptionalTableUpdateOperation(EntityMutationTarget mutationTarget, OptionalTableUpdate optionalTableUpdate, SessionFactoryImplementor factory) Description copied from class:Dialect
Create aMutationOperation
for a updating an optional table- Overrides:
createOptionalTableUpdateOperation
in classPostgreSQLDialect
-
getSqlAstTranslatorFactory
Description copied from class:Dialect
- Overrides:
getSqlAstTranslatorFactory
in classPostgreSQLDialect
- See Also:
-