Class ConstraintUnique

  • All Implemented Interfaces:
    java.lang.Comparable<Constraint>, HasSQL

    public class ConstraintUnique
    extends Constraint
    A unique constraint. This object always backed by a unique index.
    • Constructor Detail

      • ConstraintUnique

        public ConstraintUnique​(Schema schema,
                                int id,
                                java.lang.String name,
                                Table table,
                                boolean primaryKey,
                                IndexColumn[] indexColumns,
                                Index index,
                                boolean indexOwner,
                                NullsDistinct nullsDistinct)
        Parameters:
        schema - constraint belongs to
        id - of the constraint
        name - of the constraint
        table - constraint belongs to
        primaryKey - true if primary key constraint
        indexColumns - used by this constraint
        index - the index
        indexOwner - true if the index is generated by the system and belongs to this constraint
        nullsDistinct - NULL handling mode
    • Method Detail

      • getCreateSQLForCopy

        public java.lang.String getCreateSQLForCopy​(Table forTable,
                                                    java.lang.String quotedName)
        Description copied from class: DbObject
        Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table
        Overrides:
        getCreateSQLForCopy in class DbObject
        Parameters:
        forTable - the new table
        quotedName - the quoted name
        Returns:
        the SQL statement
      • getCreateSQLWithoutIndexes

        public java.lang.String getCreateSQLWithoutIndexes()
        Description copied from class: Constraint
        Get the SQL statement to create this constraint.
        Specified by:
        getCreateSQLWithoutIndexes in class Constraint
        Returns:
        the SQL statement
      • getCreateSQL

        public java.lang.String getCreateSQL()
        Description copied from class: DbObject
        Construct the CREATE ... SQL statement for this object.
        Specified by:
        getCreateSQL in class DbObject
        Returns:
        the SQL statement
      • removeChildrenAndResources

        public void removeChildrenAndResources​(SessionLocal session)
        Description copied from class: DbObject
        Delete all dependent children objects and resources of this object.
        Specified by:
        removeChildrenAndResources in class DbObject
        Parameters:
        session - the session
      • checkRow

        public void checkRow​(SessionLocal session,
                             Table t,
                             Row oldRow,
                             Row newRow)
        Description copied from class: Constraint
        Check if this row fulfils the constraint. This method throws an exception if not.
        Specified by:
        checkRow in class Constraint
        Parameters:
        session - the session
        t - the table
        oldRow - the old row
        newRow - the new row
      • usesIndex

        public boolean usesIndex​(Index idx)
        Description copied from class: Constraint
        Check if this constraint needs the specified index.
        Specified by:
        usesIndex in class Constraint
        Parameters:
        idx - the index
        Returns:
        true if the index is used
      • setIndexOwner

        public void setIndexOwner​(Index index)
        Description copied from class: Constraint
        This index is now the owner of the specified index.
        Specified by:
        setIndexOwner in class Constraint
        Parameters:
        index - the index
      • getReferencedColumns

        public java.util.HashSet<Column> getReferencedColumns​(Table table)
        Description copied from class: Constraint
        Get all referenced columns.
        Specified by:
        getReferencedColumns in class Constraint
        Parameters:
        table - the table
        Returns:
        the set of referenced columns
      • isBefore

        public boolean isBefore()
        Description copied from class: Constraint
        Check if this constraint needs to be checked before updating the data.
        Specified by:
        isBefore in class Constraint
        Returns:
        true if it must be checked before updating
      • checkExistingData

        public void checkExistingData​(SessionLocal session)
        Description copied from class: Constraint
        Check the existing data. This method is called if the constraint is added after data has been inserted into the table.
        Specified by:
        checkExistingData in class Constraint
        Parameters:
        session - the session
      • getIndex

        public Index getIndex()
        Description copied from class: Constraint
        Get the index of this constraint in the source table, or null if no index is used.
        Overrides:
        getIndex in class Constraint
        Returns:
        the index
      • rebuild

        public void rebuild()
        Description copied from class: Constraint
        This method is called after a related table has changed (the table was renamed, or columns have been renamed).
        Specified by:
        rebuild in class Constraint
      • getNullsDistinct

        public NullsDistinct getNullsDistinct()
        Returns:
        are nulls distinct