Package org.jboss.dna.common.jdbc.model.api

Examples of org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn


    }

    public void testAddColumn() {
        String COLUMN_NAME = "My column";
        // create column
        ForeignKeyColumn column = new DefaultModelFactory().createForeignKeyColumn();
        // set name
        column.setName(COLUMN_NAME);
        // add column
        bean.addColumn(column);
        // check
        assertFalse("Column set should not be empty", bean.getColumns().isEmpty());
    }
View Full Code Here


    }

    public void testDeleteColumn() {
        String COLUMN_NAME = "My column";
        // create column
        ForeignKeyColumn column = new DefaultModelFactory().createForeignKeyColumn();
        // set name
        column.setName(COLUMN_NAME);
        // add column
        bean.addColumn(column);
        // check
        assertFalse("Column set should not be empty", bean.getColumns().isEmpty());
View Full Code Here

    }

    public void testFindColumnByName() {
        String COLUMN_NAME = "My column";
        // create column
        ForeignKeyColumn column = new DefaultModelFactory().createForeignKeyColumn();
        // set name
        column.setName(COLUMN_NAME);
        // add column
        bean.addColumn(column);
        // check
        assertSame("Unable to find column", column, bean.findColumnByName(COLUMN_NAME));
    }
View Full Code Here

                if (failOnError && (tableColumn == null)) {
                    throw new DatabaseMetaDataMethodException(errMessage, "populateForeignKeys");
                }

                // create FK column
                ForeignKeyColumn fkColumn = factory.createForeignKeyColumn();

                // check if we found the original table column
                if (tableColumn != null) {
                    // mark original table column as part of FK
                    tableColumn.setForeignKeyColumn(Boolean.TRUE);
                    // clone properties from original table column to the fkcolumn
                    PropertyUtils.copyProperties(fkColumn, tableColumn);
                } else { // recovery if table column is not found but we still want to create fk column
                    // set name at least
                    fkColumn.setName(fkColumnName);
                }
                // modify ordinal position that correspond to the position in FK
                fkColumn.setOrdinalPosition(ordinalPosition);

                // check for PK table and corresponding PK column
                Table pkTable = database.findTableByName(pkTableCatalogName, pkTableSchemaName, pkTableName);
                // sets the scope table of a foreign key.
                fk.setSourceTable(pkTable);
                // find PK
                PrimaryKey pk = (pkTable == null) ? null : pkTable.getPrimaryKey();
                // set
                fk.setSourcePrimaryKey(pk);

                // What happens to a foreign key when the primary key is updated
                fk.setUpdateRule(getKeyModifyRuleType(updateRule));
                // What happens to a foreign key when the primary key is deleted
                fk.setDeleteRule(getKeyModifyRuleType(deleteRule));
                // Can the evaluation of foreign key constraints be deferred until commit
                fk.setDeferrability(getKeyDeferrabilityType(defferability));

                // find PK table column
                TableColumn pkColumn = (pkTable == null) ? null : pkTable.findColumnByName(pkColumnName);
                // Sets mapped source column (in PK/source table) for this foreign key column
                fkColumn.setSourceColumn(pkColumn);

                // add FK column to the foreign key
                fk.addColumn(fkColumn);
            }
        }
View Full Code Here

TOP

Related Classes of org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.