Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.ForeignKey


                    } else if(curIndex.isConnectedToFK()) {
                        // this is the constructed referencing index, its IndexName is the foreign key constraint name
                        name = curIndex.getIndexName().getName();
                        type = "FOREIGN KEY";
                       
                        ForeignKey fk = curTable.getReferencingForeignKey(curIndex.getIndexName().getName());
                        isDeferrable = fk.isDeferrable();
                        isInitiallyDeferred = fk.isInitiallyDeferred();
                        return true;
                    }
                }
                indexIt = null;
                curIndex = null;
View Full Code Here


                if (schemaName == null)
                    schemaName = server.getDefaultSchemaName();
                Schema schema = server.getAIS().getSchema(schemaName);
                if (schema == null)
                    throw new NoSuchSchemaException(schemaName);
                ForeignKey foreignKey = null;
                for (Table table : schema.getTables().values()) {
                    ForeignKey tfk = table.getReferencingForeignKey(constraintName.getTableName());
                    if (tfk != null) {
                        if (foreignKey == null)
                            foreignKey = tfk;
                    }
                }
View Full Code Here

                    TableDDL.addJoin(builder, fk, defaultSchema, newName.getSchemaName(), newName.getTableName());
                }
            } else {
                if(fk.getConstraintType() == ConstraintType.DROP) {
                    String name = fk.getConstraintName().getTableName();
                    ForeignKey tableFK = null;
                    for (ForeignKey tfk : tableCopy.getReferencingForeignKeys()) {
                        if (name.equals(tfk.getConstraintName().getTableName())) {
                            tableFK = tfk;
                            break;
                        }
View Full Code Here

    public void selfFK() throws Exception {
        executeDDL("CREATE TABLE t(id1 INT NOT NULL PRIMARY KEY, id2 INT, FOREIGN KEY(id2) REFERENCES t(id1))");
        Table t = ais().getTable("test", "t");
        assertNotNull(t);
        assertEquals(1, t.getForeignKeys().size());
        ForeignKey fk = t.getForeignKeys().iterator().next();
        assertEquals(t, fk.getReferencedTable());
        assertEquals(fk.getReferencedTable(), fk.getReferencingTable());
    }
View Full Code Here

                do {
                    if(!it.next()) {
                        return null;
                    }
                } while (!it.isForeignKey());
                ForeignKey fk = it.getTable().getReferencingForeignKey(it.getIndex().getIndexName().getName());
                return new ValuesRow(rowType,
                        null,   //constraint catalog
                         fk.getConstraintName().getSchemaName(),
                         fk.getConstraintName().getTableName(),
                         null,          //unique_constraint catalog
                         fk.getReferencedIndex().getConstraintName().getSchemaName(),
                         fk.getReferencedIndex().getConstraintName().getTableName(),
                         "NONE",
                         fk.getUpdateAction().toSQL(),
                         fk.getDeleteAction().toSQL(),
                         ++rowCounter /*hidden pk*/);
            }
View Full Code Here

                } else if(indexColIt != null && indexColIt.hasNext()) {
                    IndexColumn indexColumn = indexColIt.next();
                    colName = indexColumn.getColumn().getName();
                    constraintName = indexColumn.getIndex().getConstraintName() == null ? null : indexColumn.getIndex().getConstraintName().getTableName();
                    if (it.isForeignKey()) {
                        ForeignKey fk = it.getTable().getReferencingForeignKey(it.getIndex().getIndexName().getName());
                        posInUnique = findPosInIndex(fk.getReferencedColumns().get(indexColumn.getPosition()), fk.getReferencedIndex()).longValue();
                        //this is the constructed referencing index, its IndexName is the foreign key constraint name
                        constraintName = indexColumn.getIndex().getIndexName().getName();
                    }
                } else if(it.next()) {
                    joinColIt = null;
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.ForeignKey

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.