Package org.apache.openjpa.jdbc.schema

Examples of org.apache.openjpa.jdbc.schema.PrimaryKey.addColumn()


    public void testColumnRemoval() {
        Table table = _schema.addTable("table");
        Column c1 = table.addColumn("c1");
        Column c2 = table.addColumn("c2");
        PrimaryKey pk = table.addPrimaryKey("pk");
        pk.addColumn(c1);
        Index idx1 = table.addIndex("idx1");
        idx1.addColumn(c1);
        Index idx2 = table.addIndex("idx2");
        idx2.addColumn(c1);
        idx2.addColumn(c2);
View Full Code Here


        Table table2 = _schema.addTable("table2");
        Column c3 = table2.addColumn("c3");
        Column c4 = table2.addColumn("c4");
        pk = table2.addPrimaryKey("pk2");
        pk.addColumn(c3);
        ForeignKey fk = table.addForeignKey("fk");
        fk.join(c1, c3);

        table.removeColumn(c1);
        assertNull(table.getPrimaryKey());
View Full Code Here

        // add primary key columns to table pk if logical
        field.mapPrimaryKey(adapt);
        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey() && pk != null && (adapt || pk.isLogical()))
            pk.addColumn(cols[0]);

        // set joinable
        field.getDefiningMapping().setJoinable(field.getColumns()[0], this);
    }
View Full Code Here

        // add primary key columns to table pk if logical
        field.mapPrimaryKey(adapt);
        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey() && pk != null && (adapt || pk.isLogical()))
            for (int i = 0; i < _cols.length; i++)
                pk.addColumn(_cols[i]);

        // set joinable
        if (!field.getHandler().objectValueRequiresLoad(field))
            for (int i = 0; i < _cols.length; i++)
                field.getDefiningMapping().setJoinable(_cols[i], this);
View Full Code Here

        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey()) {
            Column[] cols = field.getColumns();
            if (pk != null && (adapt || pk.isLogical()))
                for (int i = 0; i < cols.length; i++)
                    pk.addColumn(cols[i]);
            for (int i = 0; i < cols.length; i++)
                field.getDefiningMapping().setJoinable(cols[i], this);
        }

        // map constraints after pk so we don't re-index / re-unique pk col
View Full Code Here

        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey()) {
            Column[] cols = field.getColumns();
            if (pk != null && (adapt || pk.isLogical()))
                for (int i = 0; i < cols.length; i++)
                    pk.addColumn(cols[i]);
            for (int i = 0; i < cols.length; i++)
                field.getDefiningMapping().setJoinable(cols[i], this);
        }

        // map constraints after pk so we don't re-index / re-unique pk col
View Full Code Here

        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey()) {
            Column[] cols = field.getColumns();
            if (pk != null && (adapt || pk.isLogical()))
                for (int i = 0; i < cols.length; i++)
                    pk.addColumn(cols[i]);
            for (int i = 0; i < cols.length; i++)
                field.getDefiningMapping().setJoinable(cols[i], this);
        }

        // map constraints after pk so we don't re-index / re-unique pk col
View Full Code Here

        Schema schema = group.addSchema(schemaName);

        Table table = schema.addTable(tableName);
        _pkColumn = addPrimaryKeyColumn(table);
        PrimaryKey pk = table.addPrimaryKey();
        pk.addColumn(_pkColumn);

        DBDictionary dict = _conf.getDBDictionaryInstance();
        _seqColumn = table.addColumn(dict.getValidColumnName
            (_seqColumnName, table));
        _seqColumn.setType(dict.getPreferredType(Types.BIGINT));
View Full Code Here

        // add primary key columns to table pk if logical
        field.mapPrimaryKey(adapt);
        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey() && pk != null && (adapt || pk.isLogical()))
            pk.addColumn(cols[0]);

        // set joinable
        field.getDefiningMapping().setJoinable(field.getColumns()[0], this);
    }
View Full Code Here

        PrimaryKey pk = field.getTable().getPrimaryKey();
        if (field.isPrimaryKey()) {
            Column[] cols = field.getColumns();
            if (pk != null && (adapt || pk.isLogical()))
                for (int i = 0; i < cols.length; i++)
                    pk.addColumn(cols[i]);
            for (int i = 0; i < cols.length; i++)
                field.getDefiningMapping().setJoinable(cols[i], this);
        }

        // map constraints after pk so we don't re-index / re-unique pk col
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.