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
public class PostgresPlusDialect extends PostgreSQLDialect
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, LEGACY_LOB_MERGE_STRATEGY, LOG_BASE2OF10, NEW_LOCATOR_LOB_MERGE_STRATEGY, QUOTE, STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY
-
-
Constructor Summary
Constructors Constructor Description PostgresPlusDialect()
Constructs a PostgresPlusDialectPostgresPlusDialect(DatabaseVersion version)
PostgresPlusDialect(DialectResolutionInfo info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
castPattern(CastType from, CastType to)
Obtain a pattern for the SQL equivalent to acast()
function call.MutationOperation
createOptionalTableUpdateOperation(EntityMutationTarget mutationTarget, OptionalTableUpdate optionalTableUpdate, SessionFactoryImplementor factory)
Create aMutationOperation
for a updating an optional tableString
currentTimestamp()
Translation of the HQL/JPQLcurrent_timestamp
function, which maps to the Java typeTimestamp
which is a datetime with no time zone.ResultSet
getResultSet(CallableStatement ps)
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from theOUT
parameter.String
getSelectGUIDString()
Get the command used to select a GUID from the database.void
initializeFunctionRegistry(FunctionContributions functionContributions)
Initialize the given registry with any dialect-specific functions.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.String
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
appendBinaryLiteral, appendBooleanValueString, appendDatetimeFormat, appendDateTimeLiteral, appendDateTimeLiteral, appendDateTimeLiteral, augmentRecognizedTableTypes, buildIdentifierHelper, buildSQLExceptionConversionDelegate, canBatchTruncate, castType, columnType, contributePostgreSQLTypes, contributeTypes, currentTime, currentTimestampWithTimeZone, datetimeFormat, extractField, extractPattern, getAggregateSupport, getAlterColumnTypeString, getCallableStatementSupport, getCascadeConstraintsString, getCaseInsensitiveLike, getCurrentSchemaCommand, getCurrentTimestampSelectString, getDefaultNonContextualLobCreation, getDefaultStatementBatchSize, getFallbackSqmInsertStrategy, getFallbackSqmMutationStrategy, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateSkipLockedString, getForUpdateSkipLockedString, getForUpdateString, getForUpdateString, getFractionalSecondPrecisionInNanos, getGroupBySelectItemReferenceStrategy, getIdentityColumnSupport, getLimitHandler, getMaxIdentifierLength, getMaxVarbinaryLength, getMaxVarcharCapacity, getMaxVarcharLength, getMinimumSupportedVersion, getNameQualifierSupport, getNationalizationSupport, getNativeIdentifierGeneratorStrategy, getNativeParameterMarkerStrategy, getNoColumnsInsertString, getQuerySequencesString, getReadLockString, getReadLockString, getResultSet, getResultSet, getSelectClauseNullString, getSequenceSupport, getSqlAstTranslatorFactory, getTimeZoneSupport, getUniqueDelegate, getViolatedConstraintNameExtractor, getWriteLockString, getWriteLockString, getWriteRowLockStrategy, isCurrentTimestampSelectStringCallable, qualifyIndexName, registerColumnTypes, requiresParensForTupleDistinctCounts, resolveSqlTypeCode, resolveSqlTypeDescriptor, rowId, rowIdSqlType, supportsAlterColumnType, supportsCaseInsensitiveLike, supportsCommentOn, supportsCurrentTimestampSelection, supportsDistinctFromPredicate, supportsFetchClause, supportsIfExistsAfterAlterTable, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTableName, supportsIfExistsBeforeTypeName, supportsInsertReturning, supportsJdbcConnectionLobCreation, supportsLateral, supportsLobValueChangePropagation, supportsMaterializedLobAccess, supportsMinMaxOnUuid, supportsNonQueryWithCTE, supportsNoWait, supportsOffsetInSubquery, supportsOuterJoinForUpdate, supportsPartitionBy, supportsRecursiveCTE, supportsSkipLocked, supportsStandardArrays, supportsTemporalLiteralOffset, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsValuesList, supportsWait, supportsWindowFunctions, timestampaddPattern, translateExtractField, useInputStreamToInsertBlob
-
Methods inherited from class org.hibernate.dialect.Dialect
addSqlHintOrComment, appendArrayLiteral, appendIntervalLiteral, appendLiteral, appendLockHint, appendUUIDLiteral, applyLocksToSql, augmentPhysicalTableTypes, canCreateCatalog, canCreateSchema, canDisableConstraints, checkVersion, closeQuote, contribute, contributeFunctions, currentDate, currentLocalTime, currentLocalTimestamp, defaultScrollMode, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, dropConstraints, equivalentTypes, escapeComment, forceLobAsLastValue, generatedAs, getAddColumnString, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAlterTableString, getArrayTypeName, getAuxiliaryDatabaseObjectExporter, getBatchLoadSizingStrategy, getCheckCondition, getCheckCondition, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateIndexString, getCreateIndexTail, getCreateMultisetTableString, getCreateSchemaCommand, getCreateTableString, getCreateTemporaryTableColumnAnnotation, getCreateUserDefinedTypeExtensionsString, getCreateUserDefinedTypeKindString, getDefaultDecimalPrecision, getDefaultLobLength, getDefaultProperties, getDefaultTimestampPrecision, getDefaultUseGetGeneratedKeys, getDisableConstraintsStatement, getDisableConstraintStatement, getDmlTargetColumnQualifierSupport, getDoublePrecision, getDropCatalogCommand, getDropForeignKeyString, getDropSchemaCommand, getDropTableString, getDropUniqueKeyString, getEnableConstraintsStatement, getEnableConstraintStatement, getEnumTypeDeclaration, getFallbackSchemaManagementTool, getFloatPrecision, getForeignKeyExporter, getForUpdateString, getForUpdateString, getForUpdateString, getHqlTranslator, getIndexExporter, getInExpressionCountLimit, getKeywords, getLobMergeStrategy, getLockingStrategy, getLockRowIdentifier, getLowercaseFunction, getMaxAliasLength, getMaxNVarcharCapacity, getMaxNVarcharLength, getMaxVarbinaryCapacity, getMultiKeyLoadSizingStrategy, getNativeIdentifierGenerationType, getNullColumnString, getNullColumnString, getNullOrdering, getParameterCountLimit, getPreferredSqlTypeCodeForArray, getPreferredSqlTypeCodeForBoolean, getQueryHintString, getQueryHintString, getReadRowLockStrategy, getRowIdColumnString, getSchemaNameResolver, getSequenceExporter, getSequenceInformationExtractor, getSizeStrategy, getSqmTranslatorFactory, getSupportedTemporaryTableKind, getTableCleaner, getTableComment, getTableExporter, getTableMigrator, getTableTypeString, getTemporaryTableAfterUseAction, getTemporaryTableBeforeUseAction, getTemporaryTableCreateCommand, getTemporaryTableCreateOptions, getTemporaryTableDdlTransactionHandling, getTemporaryTableDropCommand, getTemporaryTableExporter, getTemporaryTableTruncateCommand, getTimeoutInSeconds, getTruncateTableStatement, getTruncateTableStatements, getUniqueKeyExporter, getUserDefinedTypeComment, getUserDefinedTypeExporter, getVersion, hasAlterTable, hasDataTypeBeforeGeneratedAs, hasSelfReferentialForeignKeyBug, initDefaultProperties, inlineLiteral, isAnsiNullOn, isEmptyStringTreatedAsNull, isJdbcLogWarningsEnabledByDefault, isLob, isLockTimeoutParameterized, openQuote, ordinal, prependComment, quote, registerDefaultKeywords, registerKeyword, registerKeywords, registerResultSetOutParameter, requiresCastForConcatenatingNonStrings, requiresFloatCastingOfIntegerDivision, requiresParensForTupleCounts, resolveSqlTypeCode, resolveSqlTypeLength, supportsBindAsCallableArgument, supportsBitType, supportsCascadeDelete, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsFractionalTimestampArithmetic, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsAfterTypeName, supportsInsertReturningGeneratedKeys, supportsLockTimeouts, supportsNamedParameters, supportsNoColumnsInsert, supportsNullPrecedence, supportsOrderByInSubquery, supportsOrdinalSelectItemReference, supportsParametersInInsertSelect, supportsPredicateAsExpression, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsStandardCurrentTimestampFunction, supportsSubqueryInSelect, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTemporaryTablePrimaryKey, supportsTemporaryTables, supportsTruncateWithCast, supportsTupleDistinctCounts, supportsUnionAll, supportsUnionInSubquery, supportsValuesListForInsert, toBooleanValueString, toQuotedIdentifier, toString, transformSelectString, translateDurationField, trimPattern, useArrayForMultiValuedParameters, useFollowOnLocking, useMaterializedLobWhenCapacityExceeded
-
-
-
-
Constructor Detail
-
PostgresPlusDialect
public PostgresPlusDialect()
Constructs a PostgresPlusDialect
-
PostgresPlusDialect
public PostgresPlusDialect(DialectResolutionInfo info)
-
PostgresPlusDialect
public PostgresPlusDialect(DatabaseVersion version)
-
-
Method Detail
-
initializeFunctionRegistry
public void initializeFunctionRegistry(FunctionContributions functionContributions)
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])
-
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)
-
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
public String castPattern(CastType from, CastType to)
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 classDialect
- Parameters:
from
- aCastType
indicating the type of the value argumentto
- aCastType
indicating the type the value argument is cast to
-
currentTimestamp
public String 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
-
registerResultSetOutParameter
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException
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.
-
getResultSet
public ResultSet getResultSet(CallableStatement ps) throws SQLException
Description copied from class:Dialect
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from theOUT
parameter.- Overrides:
getResultSet
in classPostgreSQLDialect
- Parameters:
ps
- The callable statement.- Returns:
- The extracted result set.
- Throws:
SQLException
- Indicates problems extracting the result set.
-
getSelectGUIDString
public String 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
-
-