Top Description Fields Constructors Methods
org.hibernate.dialect

public Class PostgresPlusDialect

extends PostgreSQLDialect
Class Inheritance
Imports
java.sql.CallableStatement, .ResultSet, .SQLException, .Types, org.hibernate.boot.model.FunctionContributions, org.hibernate.dialect.function.CommonFunctionFactory, org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.persister.entity.mutation.EntityMutationTarget, org.hibernate.query.sqm.CastType, .TemporalUnit, org.hibernate.sql.model.MutationOperation, org.hibernate.sql.model.internal.OptionalTableUpdate, org.hibernate.sql.model.jdbc.OptionalTableUpdateOperation, jakarta.persistence.TemporalType

An SQL dialect for Postgres Plus
Author
Jim Mlodgenski

Field Summary

Inherited from org.hibernate.dialect.PostgreSQLDialect:
driverKindMINIMUM_VERSION

Constructor Summary

AccessConstructor and Description
public
PostgresPlusDialect()

Constructs a PostgresPlusDialect

public
public

Method Summary

Modifier and TypeMethod and Description
public String
castPattern(CastType
a CastType indicating the type of the value argument
from
,
CastType
a CastType indicating the type the value argument is cast to
to
)

Overrides org.hibernate.dialect.Dialect.castPattern.

Obtain a pattern for the SQL equivalent to a cast() function call.
public MutationOperation
createOptionalTableUpdateOperation(EntityMutationTarget mutationTarget, OptionalTableUpdate optionalTableUpdate, SessionFactoryImplementor factory)

Overrides org.hibernate.dialect.PostgreSQLDialect.createOptionalTableUpdateOperation.

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Create a MutationOperation for a updating an optional table
public String
currentTimestamp()

Overrides org.hibernate.dialect.PostgreSQLDialect.currentTimestamp.

Translation of the HQL/JPQL current_timestamp function, which maps to the Java type java.sql.Timestamp which is a datetime with no time zone.
public ResultSet
getResultSet(CallableStatement
The callable statement.
ps
)

Overrides org.hibernate.dialect.PostgreSQLDialect.getResultSet.

Given a callable statement previously processed by registerResultSetOutParameter, extract the ResultSet from the OUT parameter.
public String
getSelectGUIDString()

Overrides org.hibernate.dialect.Dialect.getSelectGUIDString.

Get the command used to select a GUID from the database.
public void
initializeFunctionRegistry(FunctionContributions functionContributions)

Overrides org.hibernate.dialect.PostgreSQLDialect.initializeFunctionRegistry.

Initialize the given registry with any dialect-specific functions.
public int
registerResultSetOutParameter(CallableStatement
The callable statement.
statement
,
int
The bind position at which to register the output param.
col
)

Overrides org.hibernate.dialect.PostgreSQLDialect.registerResultSetOutParameter.

Registers a parameter capable of returning a ResultSet by position, either an OUT parameter, or a REF_CURSOR parameter as defined in Java 8.
public String
timestampdiffPattern(TemporalUnit
the first argument
unit
,
TemporalType
true if the first argument is a timestamp, false if a date
fromTemporalType
,
TemporalType
true if the second argument is
toTemporalType
)

Overrides org.hibernate.dialect.PostgreSQLDialect.timestampdiffPattern.

Obtain a pattern for the SQL equivalent to a timestampdiff() function call.
Inherited from org.hibernate.dialect.PostgreSQLDialect:
addSqlHintOrCommentappendBinaryLiteralappendBooleanValueStringappendDatetimeFormatappendDateTimeLiteralappendDateTimeLiteralappendDateTimeLiteralaugmentRecognizedTableTypesbuildIdentifierHelperbuildSQLExceptionConversionDelegatecanBatchTruncatecastTypecolumnTypecontributePostgreSQLTypescontributeTypescurrentTimecurrentTimestampWithTimeZonedatetimeFormatextractFieldextractPatterngetAggregateSupportgetAlterColumnTypeStringgetCallableStatementSupportgetCascadeConstraintsStringgetCaseInsensitiveLikegetCreateEnumTypeCommandgetCurrentSchemaCommandgetCurrentTimestampSelectStringgetDefaultIntervalSecondScalegetDefaultNonContextualLobCreationgetDefaultStatementBatchSizegetDropEnumTypeCommandgetEnumTypeDeclarationgetFallbackSqmInsertStrategygetFallbackSqmMutationStrategygetForUpdateNowaitStringgetForUpdateNowaitStringgetForUpdateSkipLockedStringgetForUpdateSkipLockedStringgetForUpdateStringgetForUpdateStringgetFractionalSecondPrecisionInNanosgetFunctionalDependencyAnalysisSupportgetGroupBySelectItemReferenceStrategygetIdentityColumnSupportgetLimitHandlergetMaxIdentifierLengthgetMaxVarbinaryLengthgetMaxVarcharCapacitygetMaxVarcharLengthgetMinimumSupportedVersiongetNameQualifierSupportgetNationalizationSupportgetNativeIdentifierGeneratorStrategygetNativeParameterMarkerStrategygetNoColumnsInsertStringgetQueryHintStringgetQuerySequencesStringgetReadLockStringgetReadLockStringgetResultSetgetResultSetgetSelectClauseNullStringgetSequenceSupportgetSqlAstTranslatorFactorygetTimeZoneSupportgetUniqueDelegategetViolatedConstraintNameExtractorgetWriteLockStringgetWriteLockStringgetWriteRowLockStrategyisCurrentTimestampSelectStringCallablequalifyIndexNamequoteCollationregisterColumnTypesrequiresParensForTupleDistinctCountsresolveSqlTypeCoderesolveSqlTypeDescriptorrowIdrowIdSqlTypesupportsAlterColumnTypesupportsCaseInsensitiveLikesupportsCommentOnsupportsCurrentTimestampSelectionsupportsDistinctFromPredicatesupportsFetchClausesupportsIfExistsAfterAlterTablesupportsIfExistsBeforeConstraintNamesupportsIfExistsBeforeTableNamesupportsIfExistsBeforeTypeNamesupportsInsertReturningsupportsIsTruesupportsJdbcConnectionLobCreationsupportsLateralsupportsLobValueChangePropagationsupportsMaterializedLobAccesssupportsMinMaxOnUuidsupportsNonQueryWithCTEsupportsNoWaitsupportsOffsetInSubquerysupportsOuterJoinForUpdatesupportsPartitionBysupportsRecursiveCTEsupportsSkipLockedsupportsStandardArrayssupportsTemporalLiteralOffsetsupportsTupleCountssupportsUnboundedLobLocatorMaterializationsupportsValuesListsupportsWaitsupportsWindowFunctionstimestampaddPatterntranslateExtractFielduseInputStreamToInsertBlob

Constructor Detail

PostgresPlusDialectback to summary
public PostgresPlusDialect()

Constructs a PostgresPlusDialect

PostgresPlusDialectback to summary
public PostgresPlusDialect(DialectResolutionInfo info)
PostgresPlusDialectback to summary
public PostgresPlusDialect(DatabaseVersion version)

Method Detail

castPatternback to summary
public String castPattern(CastType from, CastType to)

Overrides org.hibernate.dialect.Dialect.castPattern.

Doc from org.hibernate.dialect.Dialect.castPattern.

Obtain a pattern for the SQL equivalent to a cast() function call. The resulting pattern must contain ?1 and ?2 placeholders for the arguments.

Parameters
from:CastType

a CastType indicating the type of the value argument

to:CastType

a CastType indicating the type the value argument is cast to

Annotations
@Override
createOptionalTableUpdateOperationback to summary
public MutationOperation createOptionalTableUpdateOperation(EntityMutationTarget mutationTarget, OptionalTableUpdate optionalTableUpdate, SessionFactoryImplementor factory)

Overrides org.hibernate.dialect.PostgreSQLDialect.createOptionalTableUpdateOperation.

Doc from org.hibernate.dialect.Dialect.createOptionalTableUpdateOperation.

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Create a MutationOperation for a updating an optional table

Annotations
@Override
currentTimestampback to summary
public String currentTimestamp()

Overrides org.hibernate.dialect.PostgreSQLDialect.currentTimestamp.

Doc from org.hibernate.dialect.Dialect.currentTimestamp.

Translation of the HQL/JPQL current_timestamp function, which maps to the Java type java.sql.Timestamp which is a datetime with no time zone. This contradicts ANSI SQL where current_timestamp has the type TIMESTAMP WITH TIME ZONE.

It is recommended to override this in dialects for databases which support localtimestamp or timestamp at local.

Annotations
@Override
getResultSetback to summary
public ResultSet getResultSet(CallableStatement ps) throws SQLException

Overrides org.hibernate.dialect.PostgreSQLDialect.getResultSet.

Doc from org.hibernate.dialect.Dialect.getResultSet.

Given a callable statement previously processed by registerResultSetOutParameter, extract the ResultSet from the OUT parameter.

Parameters
ps:CallableStatement

The callable statement.

Returns:ResultSet

The extracted result set.

Annotations
@Override
Exceptions
SQLException:
Indicates problems extracting the result set.
getSelectGUIDStringback to summary
public String getSelectGUIDString()

Overrides org.hibernate.dialect.Dialect.getSelectGUIDString.

Doc from org.hibernate.dialect.Dialect.getSelectGUIDString.

Get the command used to select a GUID from the database.

Optional operation.

Returns:String

The appropriate command.

Annotations
@Override
initializeFunctionRegistryback to summary
public void initializeFunctionRegistry(FunctionContributions functionContributions)

Overrides org.hibernate.dialect.PostgreSQLDialect.initializeFunctionRegistry.

Doc from org.hibernate.dialect.Dialect.initializeFunctionRegistry.

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
Along with an additional set of functions defined by ANSI SQL:
  • 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])
And the following functions for working with java.time types:
  • local date
  • local time
  • local datetime
  • offset datetime
  • instant
And a number of additional "standard" functions:
  • 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)
  • format(datetime as pattern)
  • collate(string as collation)
  • str(arg) - synonym of cast(a as String)
  • ifnull(arg0, arg1) - synonym of coalesce(a, b)
Finally, the following functions are defined as abbreviations for extract(), and desugared by the parser:
  • second(arg) - synonym of extract(second from a)
  • minute(arg) - synonym of extract(minute from a)
  • hour(arg) - synonym of extract(hour from a)
  • day(arg) - synonym of extract(day from a)
  • month(arg) - synonym of extract(month from a)
  • year(arg) - synonym of extract(year from a)
Note that according to this definition, the 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.
Annotations
@Override
registerResultSetOutParameterback to summary
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException

Overrides org.hibernate.dialect.PostgreSQLDialect.registerResultSetOutParameter.

Doc from org.hibernate.dialect.Dialect.registerResultSetOutParameter.

Registers a parameter capable of returning a ResultSet by position, either an OUT parameter, or a REF_CURSOR parameter as defined in Java 8.

Parameters
statement:CallableStatement

The callable statement.

col:int

The bind position at which to register the output param.

Returns:int

The number of (contiguous) bind positions used.

Annotations
@Override
Exceptions
SQLException:
Indicates problems registering the param.
timestampdiffPatternback to summary
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType)

Overrides org.hibernate.dialect.PostgreSQLDialect.timestampdiffPattern.

Doc from org.hibernate.dialect.Dialect.timestampdiffPattern.

Obtain a pattern for the SQL equivalent to a timestampdiff() function call. The resulting pattern must contain ?1, ?2, and ?3 placeholders for the arguments.

Parameters
unit:TemporalUnit

the first argument

fromTemporalType:TemporalType

true if the first argument is a timestamp, false if a date

toTemporalType:TemporalType

true if the second argument is

Annotations
@Override