Class PostgreSQL81Dialect

    • Constructor Detail

      • PostgreSQL81Dialect

        public PostgreSQL81Dialect()
        Constructs a PostgreSQL81Dialect
    • Method Detail

      • getSqlTypeDescriptorOverride

        public SqlTypeDescriptor getSqlTypeDescriptorOverride​(int sqlCode)
        Description copied from class: Dialect
        Returns the SqlTypeDescriptor that should be used to handle the given JDBC type code. Returns null if there is no override.
        Overrides:
        getSqlTypeDescriptorOverride in class Dialect
        Parameters:
        sqlCode - A Types constant indicating the SQL column type
        Returns:
        The SqlTypeDescriptor to use as an override, or null if there is no override.
      • getAddColumnString

        public java.lang.String getAddColumnString()
        Description copied from class: Dialect
        The syntax used to add a column to a table (optional).
        Overrides:
        getAddColumnString in class Dialect
        Returns:
        The "add column" fragment.
      • getSequenceNextValString

        public java.lang.String getSequenceNextValString​(java.lang.String sequenceName)
        Description copied from class: Dialect
        Generate the appropriate select statement to to retrieve the next value of a sequence.

        This should be a "stand alone" select statement.

        Overrides:
        getSequenceNextValString in class Dialect
        Parameters:
        sequenceName - the name of the sequence
        Returns:
        String The "nextval" select string.
      • getSelectSequenceNextValString

        public java.lang.String getSelectSequenceNextValString​(java.lang.String sequenceName)
        Description copied from class: Dialect
        Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement.

        This differs from Dialect.getSequenceNextValString(String) in that this should return an expression usable within another statement.

        Overrides:
        getSelectSequenceNextValString in class Dialect
        Parameters:
        sequenceName - the name of the sequence
        Returns:
        The "nextval" fragment.
      • getCreateSequenceString

        public java.lang.String getCreateSequenceString​(java.lang.String sequenceName)
        Description copied from class: Dialect
        Typically dialects which support sequences can create a sequence with a single command. This is convenience form of Dialect.getCreateSequenceStrings(java.lang.String) to help facilitate that.

        Dialects which support sequences and can create a sequence in a single command need *only* override this method. Dialects which support sequences but require multiple commands to create a sequence should instead override Dialect.getCreateSequenceStrings(java.lang.String).

        Overrides:
        getCreateSequenceString in class Dialect
        Parameters:
        sequenceName - The name of the sequence
        Returns:
        The sequence creation command
      • getDropSequenceString

        public java.lang.String getDropSequenceString​(java.lang.String sequenceName)
        Description copied from class: Dialect
        Typically dialects which support sequences can drop a sequence with a single command. This is convenience form of Dialect.getDropSequenceStrings(java.lang.String) to help facilitate that.

        Dialects which support sequences and can drop a sequence in a single command need *only* override this method. Dialects which support sequences but require multiple commands to drop a sequence should instead override Dialect.getDropSequenceStrings(java.lang.String).

        Overrides:
        getDropSequenceString in class Dialect
        Parameters:
        sequenceName - The name of the sequence
        Returns:
        The sequence drop commands
      • getCascadeConstraintsString

        public java.lang.String getCascadeConstraintsString()
        Description copied from class: Dialect
        Completely optional cascading drop clause
        Overrides:
        getCascadeConstraintsString in class Dialect
        Returns:
        String
      • dropConstraints

        public boolean dropConstraints()
        Description copied from class: Dialect
        Do we need to drop constraints before dropping tables in this dialect?
        Overrides:
        dropConstraints in class Dialect
        Returns:
        True if constraints must be dropped prior to dropping the table; false otherwise.
      • supportsSequences

        public boolean supportsSequences()
        Description copied from class: Dialect
        Does this dialect support sequences?
        Overrides:
        supportsSequences in class Dialect
        Returns:
        True if sequences supported; false otherwise.
      • getQuerySequencesString

        public java.lang.String getQuerySequencesString()
        Description copied from class: Dialect
        Get the select command used retrieve the names of all sequences.
        Overrides:
        getQuerySequencesString in class Dialect
        Returns:
        The select command; or null if sequences are not supported.
        See Also:
        SchemaUpdate
      • getLimitHandler

        public LimitHandler getLimitHandler()
        Description copied from class: Dialect
        Returns the delegate managing LIMIT clause.
        Overrides:
        getLimitHandler in class Dialect
        Returns:
        LIMIT clause delegate.
      • supportsLimit

        public boolean supportsLimit()
        Description copied from class: Dialect
        Does this dialect support some form of limiting query results via a SQL clause?
        Overrides:
        supportsLimit in class Dialect
        Returns:
        True if this dialect supports some form of LIMIT.
      • getLimitString

        public java.lang.String getLimitString​(java.lang.String sql,
                                               boolean hasOffset)
        Description copied from class: Dialect
        Apply s limit clause to the query.

        Typically dialects utilize variable limit clauses when they support limits. Thus, when building the select command we do not actually need to know the limit or the offest since we will just be using placeholders.

        Here we do still pass along whether or not an offset was specified so that dialects not supporting offsets can generate proper exceptions. In general, dialects will override one or the other of this method and Dialect.getLimitString(String, int, int).

        Overrides:
        getLimitString in class Dialect
        Parameters:
        sql - The query to which to apply the limit.
        hasOffset - Is the query requesting an offset?
        Returns:
        the modified SQL
      • bindLimitParametersInReverseOrder

        public boolean bindLimitParametersInReverseOrder()
        Description copied from class: Dialect
        ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit. Does this dialect require us to bind the parameters in reverse order?
        Overrides:
        bindLimitParametersInReverseOrder in class Dialect
        Returns:
        true if the correct order is limit, offset
      • getForUpdateString

        public java.lang.String getForUpdateString​(java.lang.String aliases)
        Description copied from class: Dialect
        Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.
        Overrides:
        getForUpdateString in class Dialect
        Parameters:
        aliases - The columns to be write locked.
        Returns:
        The appropriate FOR UPDATE OF column_list clause string.
      • getForUpdateString

        public java.lang.String getForUpdateString​(java.lang.String aliases,
                                                   LockOptions lockOptions)
        Description copied from class: Dialect
        Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.
        Overrides:
        getForUpdateString in class Dialect
        Parameters:
        aliases - The columns to be write locked.
        lockOptions - the lock options to apply
        Returns:
        The appropriate FOR UPDATE OF column_list clause string.
      • getNoColumnsInsertString

        public java.lang.String getNoColumnsInsertString()
        Description copied from class: Dialect
        The fragment used to insert a row without specifying any column values. This is not possible on some databases.
        Overrides:
        getNoColumnsInsertString in class Dialect
        Returns:
        The appropriate empty values clause.
      • getCaseInsensitiveLike

        public java.lang.String getCaseInsensitiveLike()
        Description copied from class: Dialect
        The name of the SQL function that can do case insensitive like comparison.
        Overrides:
        getCaseInsensitiveLike in class Dialect
        Returns:
        The dialect-specific "case insensitive" like function.
      • supportsCaseInsensitiveLike

        public boolean supportsCaseInsensitiveLike()
        Description copied from class: Dialect
        Does this dialect support case insensitive LIKE restrictions?
        Overrides:
        supportsCaseInsensitiveLike in class Dialect
        Returns:
        true if the underlying database supports case insensitive like comparison, false otherwise. The default is false.
      • getNativeIdentifierGeneratorStrategy

        public java.lang.String getNativeIdentifierGeneratorStrategy()
        Description copied from class: Dialect
        Resolves the native generation strategy associated to this dialect.

        Comes into play whenever the user specifies the native generator.

        Overrides:
        getNativeIdentifierGeneratorStrategy in class Dialect
        Returns:
        The native generator strategy.
      • supportsOuterJoinForUpdate

        public boolean supportsOuterJoinForUpdate()
        Description copied from class: Dialect
        Does this dialect support FOR UPDATE in conjunction with outer joined rows?
        Overrides:
        supportsOuterJoinForUpdate in class Dialect
        Returns:
        True if outer joined rows can be locked via FOR UPDATE.
      • useInputStreamToInsertBlob

        public boolean useInputStreamToInsertBlob()
        Description copied from class: Dialect
        Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e. PreparedStatement.setBinaryStream(int, java.io.InputStream, int)).
        Overrides:
        useInputStreamToInsertBlob in class Dialect
        Returns:
        True if BLOBs and CLOBs should be bound using stream operations.
      • supportsUnionAll

        public boolean supportsUnionAll()
        Description copied from class: Dialect
        Does this dialect support UNION ALL, which is generally a faster variant of UNION?
        Overrides:
        supportsUnionAll in class Dialect
        Returns:
        True if UNION ALL is supported; false otherwise.
      • getSelectClauseNullString

        public java.lang.String getSelectClauseNullString​(int sqlType)
        Workaround for postgres bug #1453

        Given a Types type code, determine an appropriate null value to use in a select clause.

        One thing to consider here is that certain databases might require proper casting for the nulls here since the select here will be part of a UNION/UNION ALL.

        Overrides:
        getSelectClauseNullString in class Dialect
        Parameters:
        sqlType - The Types type code.
        Returns:
        The appropriate select clause value fragment.
      • supportsCommentOn

        public boolean supportsCommentOn()
        Description copied from class: Dialect
        Does this dialect/database support commenting on tables, columns, etc?
        Overrides:
        supportsCommentOn in class Dialect
        Returns:
        true if commenting is supported
      • supportsCurrentTimestampSelection

        public boolean supportsCurrentTimestampSelection()
        Description copied from class: Dialect
        Does this dialect support a way to retrieve the database's current timestamp value?
        Overrides:
        supportsCurrentTimestampSelection in class Dialect
        Returns:
        True if the current timestamp can be retrieved; false otherwise.
      • getCurrentTimestampSelectString

        public java.lang.String getCurrentTimestampSelectString()
        Description copied from class: Dialect
        Retrieve the command used to retrieve the current timestamp from the database.
        Overrides:
        getCurrentTimestampSelectString in class Dialect
        Returns:
        The command.
      • toBooleanValueString

        public java.lang.String toBooleanValueString​(boolean bool)
        Description copied from class: Dialect
        The SQL literal value to which this database maps boolean values.
        Overrides:
        toBooleanValueString in class Dialect
        Parameters:
        bool - The boolean value
        Returns:
        The appropriate SQL literal.
      • buildSQLExceptionConversionDelegate

        public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
        Description copied from class: Dialect
        Build an instance of a SQLExceptionConversionDelegate for interpreting dialect-specific error or SQLState codes.

        When Dialect.buildSQLExceptionConverter() returns null, the default SQLExceptionConverter is used to interpret SQLState and error codes. If this method is overridden to return a non-null value, the default SQLExceptionConverter will use the returned SQLExceptionConversionDelegate in addition to the following standard delegates:

        1. a "static" delegate based on the JDBC 4 defined SQLException hierarchy;
        2. a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes, depending on java.sql.DatabaseMetaData#getSQLStateType

        It is strongly recommended that specific Dialect implementations override this method, since interpretation of a SQL error is much more accurate when based on the a vendor-specific ErrorCode rather than the SQLState.

        Specific Dialects may override to return whatever is most appropriate for that vendor.

        Overrides:
        buildSQLExceptionConversionDelegate in class Dialect
        Returns:
        The SQLExceptionConversionDelegate for this dialect
      • registerResultSetOutParameter

        public int registerResultSetOutParameter​(java.sql.CallableStatement statement,
                                                 int col)
                                          throws java.sql.SQLException
        Description copied from class: Dialect
        Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returning ResultSet *by position*. Pre-Java 8, registering such ResultSet-returning parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.
        Overrides:
        registerResultSetOutParameter in class Dialect
        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:
        java.sql.SQLException - Indicates problems registering the param.
      • getResultSet

        public java.sql.ResultSet getResultSet​(java.sql.CallableStatement ps)
                                        throws java.sql.SQLException
        Description copied from class: Dialect
        Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.
        Overrides:
        getResultSet in class Dialect
        Parameters:
        ps - The callable statement.
        Returns:
        The extracted result set.
        Throws:
        java.sql.SQLException - Indicates problems extracting the result set.
      • getCreateSequenceString

        protected java.lang.String getCreateSequenceString​(java.lang.String sequenceName,
                                                           int initialValue,
                                                           int incrementSize)
        only necessary for postgre < 7.4 See http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/create_sequence.sgml

        Overloaded form of Dialect.getCreateSequenceString(String), additionally taking the initial value and increment size to be applied to the sequence definition.

        The default definition is to suffix Dialect.getCreateSequenceString(String) with the string: " start with {initialValue} increment by {incrementSize}" where {initialValue} and {incrementSize} are replacement placeholders. Generally dialects should only need to override this method if different key phrases are used to apply the allocation information.
        Overrides:
        getCreateSequenceString in class Dialect
        Parameters:
        sequenceName - The name of the sequence
        initialValue - The initial value to apply to 'create sequence' statement
        incrementSize - The increment value to apply to 'create sequence' statement
        Returns:
        The sequence creation command
      • supportsEmptyInList

        public boolean supportsEmptyInList()
        Description copied from class: Dialect
        Does this dialect support empty IN lists?

        For example, is [where XYZ in ()] a supported construct?

        Overrides:
        supportsEmptyInList in class Dialect
        Returns:
        True if empty in lists are supported; false otherwise.
      • supportsExpectedLobUsagePattern

        public boolean supportsExpectedLobUsagePattern()
        Description copied from class: Dialect
        Expected LOB usage pattern is such that I can perform an insert via prepared statement with a parameter binding for a LOB value without crazy casting to JDBC driver implementation-specific classes...

        Part of the trickiness here is the fact that this is largely driver dependent. For example, Oracle (which is notoriously bad with LOB support in their drivers historically) actually does a pretty good job with LOB support as of the 10.2.x versions of their drivers...

        Overrides:
        supportsExpectedLobUsagePattern in class Dialect
        Returns:
        True if normal LOB usage patterns can be used with this driver; false if driver-specific hookiness needs to be applied.
      • supportsLobValueChangePropogation

        public boolean supportsLobValueChangePropogation()
        Description copied from class: Dialect
        Does the dialect support propagating changes to LOB values back to the database? Talking about mutating the internal value of the locator as opposed to supplying a new locator instance...

        For BLOBs, the internal value might be changed by: Blob.setBinaryStream(long), Blob.setBytes(long, byte[]), Blob.setBytes(long, byte[], int, int), or Blob.truncate(long).

        For CLOBs, the internal value might be changed by: Clob.setAsciiStream(long), Clob.setCharacterStream(long), Clob.setString(long, String), Clob.setString(long, String, int, int), or Clob.truncate(long).

        NOTE : I do not know the correct answer currently for databases which (1) are not part of the cruise control process or (2) do not Dialect.supportsExpectedLobUsagePattern().

        Overrides:
        supportsLobValueChangePropogation in class Dialect
        Returns:
        True if the changes are propagated back to the database; false otherwise.
      • supportsUnboundedLobLocatorMaterialization

        public boolean supportsUnboundedLobLocatorMaterialization()
        Description copied from class: Dialect
        Is it supported to materialize a LOB locator outside the transaction in which it was created?

        Again, part of the trickiness here is the fact that this is largely driver dependent.

        NOTE: all database I have tested which Dialect.supportsExpectedLobUsagePattern() also support the ability to materialize a LOB outside the owning transaction...

        Overrides:
        supportsUnboundedLobLocatorMaterialization in class Dialect
        Returns:
        True if unbounded materialization is supported; false otherwise.
      • getForUpdateString

        public java.lang.String getForUpdateString()
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire locks for this dialect.
        Overrides:
        getForUpdateString in class Dialect
        Returns:
        The appropriate FOR UPDATE clause string.
      • getWriteLockString

        public java.lang.String getWriteLockString​(int timeout)
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the of the returned string is treated the same as getForUpdateString.
        Overrides:
        getWriteLockString in class Dialect
        Parameters:
        timeout - in milliseconds, -1 for indefinite wait and 0 for no wait.
        Returns:
        The appropriate LOCK clause string.
      • getWriteLockString

        public java.lang.String getWriteLockString​(java.lang.String aliases,
                                                   int timeout)
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire WRITE locks for this dialect given the aliases of the columns to be write locked. Location of the of the returned string is treated the same as getForUpdateString.
        Overrides:
        getWriteLockString in class Dialect
        Parameters:
        aliases - The columns to be read locked.
        timeout - in milliseconds, -1 for indefinite wait and 0 for no wait.
        Returns:
        The appropriate LOCK clause string.
      • getReadLockString

        public java.lang.String getReadLockString​(int timeout)
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire READ locks for this dialect. Location of the of the returned string is treated the same as getForUpdateString.
        Overrides:
        getReadLockString in class Dialect
        Parameters:
        timeout - in milliseconds, -1 for indefinite wait and 0 for no wait.
        Returns:
        The appropriate LOCK clause string.
      • getReadLockString

        public java.lang.String getReadLockString​(java.lang.String aliases,
                                                  int timeout)
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire READ locks for this dialect given the aliases of the columns to be read locked. Location of the of the returned string is treated the same as getForUpdateString.
        Overrides:
        getReadLockString in class Dialect
        Parameters:
        aliases - The columns to be read locked.
        timeout - in milliseconds, -1 for indefinite wait and 0 for no wait.
        Returns:
        The appropriate LOCK clause string.
      • supportsRowValueConstructorSyntax

        public boolean supportsRowValueConstructorSyntax()
        Description copied from class: Dialect
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax.

        Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".

        Overrides:
        supportsRowValueConstructorSyntax in class Dialect
        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.
      • getForUpdateNowaitString

        public java.lang.String getForUpdateNowaitString()
        Description copied from class: Dialect
        Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.
        Overrides:
        getForUpdateNowaitString in class Dialect
        Returns:
        The appropriate FOR UPDATE NOWAIT clause string.
      • getForUpdateNowaitString

        public java.lang.String getForUpdateNowaitString​(java.lang.String aliases)
        Description copied from class: Dialect
        Get the FOR UPDATE OF column_list NOWAIT fragment appropriate for this dialect given the aliases of the columns to be write locked.
        Overrides:
        getForUpdateNowaitString in class Dialect
        Parameters:
        aliases - The columns to be write locked.
        Returns:
        The appropriate FOR UPDATE OF colunm_list NOWAIT clause string.
      • getResultSet

        public java.sql.ResultSet getResultSet​(java.sql.CallableStatement statement,
                                               int position)
                                        throws java.sql.SQLException
        Description copied from class: Dialect
        Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet.
        Overrides:
        getResultSet in class Dialect
        Parameters:
        statement - The callable statement.
        position - The bind position at which to register the output param.
        Returns:
        The extracted result set.
        Throws:
        java.sql.SQLException - Indicates problems extracting the result set.
      • getResultSet

        public java.sql.ResultSet getResultSet​(java.sql.CallableStatement statement,
                                               java.lang.String name)
                                        throws java.sql.SQLException
        Description copied from class: Dialect
        Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.
        Overrides:
        getResultSet in class Dialect
        Parameters:
        statement - The callable statement.
        name - The parameter name (for drivers which support named parameters).
        Returns:
        The extracted result set.
        Throws:
        java.sql.SQLException - Indicates problems extracting the result set.
      • qualifyIndexName

        public boolean qualifyIndexName()
        Description copied from class: Dialect
        Do we need to qualify index names with the schema name?
        Overrides:
        qualifyIndexName in class Dialect
        Returns:
        boolean
      • supportsNationalizedTypes

        public boolean supportsNationalizedTypes()
        Description copied from class: Dialect
        Does this dialect supports Nationalized Types
        Overrides:
        supportsNationalizedTypes in class Dialect
        Returns:
        boolean
      • supportsNoWait

        public boolean supportsNoWait()
        Description copied from class: Dialect
        Does this dialect/database support NO_WAIT timeout.
        Overrides:
        supportsNoWait in class Dialect
        Returns:
        true if NO_WAIT is supported