Class Table.Builder

    • Method Detail

      • setVersion

        public Table.Builder setVersion​(int v)
        Set the version
        Parameters:
        v -
        Returns:
      • setTablespace

        public Table.Builder setTablespace​(Tablespace ts)
        Setter for the tablespace
        Parameters:
        ts -
        Returns:
      • addBigIntColumn

        public Table.Builder addBigIntColumn​(String columnName,
                                             boolean nullable)
      • addDoubleColumn

        public Table.Builder addDoubleColumn​(String columnName,
                                             boolean nullable)
      • addTimestampColumn

        public Table.Builder addTimestampColumn​(String columnName,
                                                boolean nullable)
      • addTimestampColumn

        public Table.Builder addTimestampColumn​(String columnName,
                                                boolean nullable,
                                                String defaultValue)
      • addTimestampColumn

        public Table.Builder addTimestampColumn​(String columnName,
                                                int numberOfFractionalSecondDigits,
                                                boolean nullable)
      • addVarcharColumn

        public Table.Builder addVarcharColumn​(String columnName,
                                              int size,
                                              boolean nullable)
      • addVarbinaryColumn

        public Table.Builder addVarbinaryColumn​(String columnName,
                                                int size,
                                                boolean nullable)
        Add a VARBINARY(nn) column
        Parameters:
        columnName -
        size -
        nullable -
        Returns:
      • addCharColumn

        public Table.Builder addCharColumn​(String columnName,
                                           int size,
                                           boolean nullable)
        Add char (fixed-width) column
        Parameters:
        columnName -
        size -
        nullable -
        Returns:
      • addCharColumn

        public Table.Builder addCharColumn​(String columnName,
                                           int size,
                                           boolean nullable,
                                           String defaultValue)
        Add char (fixed-width) column with a default value specified
        Parameters:
        columnName -
        size -
        nullable -
        defaultValue -
        Returns:
      • addBlobColumn

        public Table.Builder addBlobColumn​(String columnName,
                                           long size,
                                           int inlineSize,
                                           boolean nullable)
      • addClobColumn

        public Table.Builder addClobColumn​(String columnName,
                                           boolean nullable,
                                           String defaultVal)
        Parameters:
        columnName -
        nullable -
        defaultVal - this value is auto-quoted; do not pass the single-quote (') within the string value
        Returns:
      • setIdentityColumn

        public Table.Builder setIdentityColumn​(String columnName,
                                               Generated generated)
        Set one of the columns to be the identity column for the table
        Parameters:
        constraintName -
        columns -
        Returns:
      • addPrimaryKey

        public Table.Builder addPrimaryKey​(String constraintName,
                                           String... columns)
        Add a primary key constraint to the table
        Parameters:
        constraintName -
        columns -
        Returns:
      • addIndex

        public Table.Builder addIndex​(String indexName,
                                      String... columns)
        Add an index to the table using the list of column names
        Parameters:
        indexName -
        columns -
        Returns:
      • addUniqueIndex

        public Table.Builder addUniqueIndex​(String indexName,
                                            String... columns)
        Add a unique index to the table using the list of column names
        Parameters:
        indexName -
        columns -
        Returns:
      • addUniqueConstraint

        public Table.Builder addUniqueConstraint​(String constraintName,
                                                 String... columnName)
        Add a unique constraint to the table/column
        Parameters:
        constraintName -
        columnName - - at least one column
        Returns:
      • addForeignKeyConstraint

        public Table.Builder addForeignKeyConstraint​(String constraintName,
                                                     String targetSchema,
                                                     String targetTable,
                                                     String... columns)
        Add a foreign key constraint pointing to the target table (with enforcement). The list of columns is expected to match the primary key definition on the target.
        Parameters:
        constraintName -
        targetSchema -
        targetTable -
        columns -
        Returns:
      • addForeignKeyConstraint

        public Table.Builder addForeignKeyConstraint​(String constraintName,
                                                     boolean enforced,
                                                     String targetSchema,
                                                     String targetTable,
                                                     String... columns)
        Add a foreign key constraint pointing to the target table. The list of columns is expected to match the primary key definition on the target
        Parameters:
        constraintName -
        enforced -
        targetSchema -
        targetTable -
        columns -
        Returns:
      • addForeignKeyConstraintSelf

        public Table.Builder addForeignKeyConstraintSelf​(String constraintName,
                                                         String targetSchema,
                                                         String targetTable,
                                                         String targetColumnName,
                                                         String... columns)
        Adds a foreign key constraint relationship on itself. This is intentionally created as a separate method, so there are no mistakes.
        Parameters:
        constraintName -
        targetSchema -
        targetTable -
        targetColumnName -
        columns -
        Returns:
      • addForeignKeyConstraintAltTarget

        public Table.Builder addForeignKeyConstraintAltTarget​(String constraintName,
                                                              String targetSchema,
                                                              String targetTable,
                                                              String targetColumnName,
                                                              String... columns)
        Adds a foreign key constraint relationship on itself. This is intentionally created as a separate method, so there are no mistakes.
        Parameters:
        constraintName -
        targetSchema -
        targetTable -
        targetColumnName -
        columns -
        Returns:
      • checkColumns

        protected void checkColumns​(String[] columns)
        Check each of the columns in the given array are valid column names
        Parameters:
        columns -
      • checkColumns

        protected void checkColumns​(Collection<String> columns)
        Check each of the columns in the given array are valid column names
        Parameters:
        columns -
      • build

        public Table build​(IDataModel dataModel)
        Build the immutable table object based on the current configuration
        Parameters:
        dataModel -
        Returns:
      • buildColumns

        protected List<ColumnBase> buildColumns()
        Create the columns for the table based on the definitions that have been added
        Returns:
      • setTenantColumnName

        public Table.Builder setTenantColumnName​(String name)
        Setter to configure this table for multitenancy. Multitenancy support depends on the target ...which in this case means DB2 supports it (using partitioning) but Derby does not...so for Derby, we don't create the extra column or FK relationships back to the TENANTS table.
        Returns:
      • addWiths

        public Table.Builder addWiths​(List<With> withs)
        adds with parameters (key-values) to the table definition.
        Parameters:
        withs -