Package org.apache.openjpa.jdbc.sql

Examples of org.apache.openjpa.jdbc.sql.Row


    public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
        throws SQLException {
        if (field.getMappedBy() != null)
            return;
        Row row = null;
        OpenJPAStateManager rel = RelationStrategies.getStateManager
            (sm.fetchObjectField(field.getIndex()), store.getContext());
        // Checks if the field being inserted is a MapsId field and
        // the related object is using auto-assigned identity
        // If the above conditions are satisfied and the related instance has
View Full Code Here


            updateInverse(sm, rel, store, rm);
        } else {
            int action = (rel == null &&
                    field.isBidirectionalJoinTableMappingNonOwner()) ?
                    Row.ACTION_DELETE : Row.ACTION_UPDATE;
            Row row = field.getRow(sm, store, rm, action);
            if (row != null && !field.isBiMTo1JT()) {
                field.setForeignKey(row, rel);
                // this is for bi-directional maps, the key and value of the
                // map are stored in the table of the mapped-by entity 
                setMapKey(sm, rel, store, row);
            }
           
            if (field.isBiMTo1JT()) { // also need to update the join table
                PersistenceCapable invPC = (PersistenceCapable)sm.fetchObject(
                    field.getBi_1ToM_JTField().getIndex());
                Row secondaryRow = null;
                if (invPC != null) {
                    secondaryRow = rm.getSecondaryRow(field.getBi1ToMJoinFK().getTable(),
                        Row.ACTION_INSERT);
                    secondaryRow.setForeignKey(field.getBi1ToMElemFK(), null, sm);
                    secondaryRow.setForeignKey(field.getBi1ToMJoinFK(), null,
                        RelationStrategies.getStateManager(invPC,
                        store.getContext()));
                    rm.flushSecondaryRow(secondaryRow);
                }
            }
View Full Code Here

            if (rel != null) {
                ForeignKey fk = field.getForeignKey((ClassMapping)
                    rel.getMetaData());
                if (fk.getDeleteAction() == ForeignKey.ACTION_RESTRICT ||
                    fk.getDeleteAction() == ForeignKey.ACTION_CASCADE) {
                    Row row = field.getRow(sm, store, rm, Row.ACTION_DELETE);
                    row.setForeignKey(fk, null, rel);
                    // this is for bi-directional maps, the key and value of the
                    // map are stored in the table of the mapped-by entity 
                    setMapKey(sm, rel, store, row);
                }
            }
View Full Code Here

            return;

        // null inverse if not already enforced by fk
        if (field.getIndependentTypeMappings().length != 1)
            throw RelationStrategies.uninversable(field);
        Row row = rm.getAllRows(fk.getTable(), Row.ACTION_UPDATE);
        row.setForeignKey(fk, io, null);
        row.whereForeignKey(fk, sm);
        rm.flushAllRows(row);
    }
View Full Code Here

        if (field.getIndependentTypeMappings().length != 1)
            throw RelationStrategies.uninversable(field);

        // get the row for the inverse object; the row might be in a secondary
        // table if there is a field controlling the foreign key
        Row row = null;
        FieldMapping[] invs = field.getInverseMappings();
        for (int i = 0; i < invs.length; i++) {
            if (invs[i].getMappedByMetaData() == field
                && invs[i].getTypeCode() == JavaTypes.PC) {
                row = invs[i].getRow(rel, store, rm, action);
                break;
            }
        }
        ClassMapping relMapping = field.getTypeMapping();
        if (row == null)
            row = rm.getRow(relMapping.getTable(), action, rel, true);

        // if this is an update, this might be the only mod to the row, so
        // make sure the where condition is set
        if (action == Row.ACTION_UPDATE
            && row.getTable() == relMapping.getTable())
            row.wherePrimaryKey(rel);

        // update the inverse pointer with our oid value
        row.setForeignKey(fk, io, sm);
    }
View Full Code Here

        OpenJPAStateManager rel = RelationStrategies.getStateManager
            (sm.fetchObjectField(field.getIndex()), store.getContext());
        if (field.getJoinDirection() == field.JOIN_INVERSE)
            updateInverse(sm, rel, store, rm);
        else {
            Row row = field.getRow(sm, store, rm, Row.ACTION_INSERT);
            if (row != null && !field.isBiMTo1JT()) {
                field.setForeignKey(row, rel);
                // this is for bi-directional maps, the key and value of the
                // map are stored in the table of the mapped-by entity 
                setMapKey(sm, rel, store, row);
View Full Code Here

            updateInverse(sm, rel, store, rm);
        } else {
            int action = (rel == null &&
                    field.isBidirectionalJoinTableMappingNonOwner()) ?
                    Row.ACTION_DELETE : Row.ACTION_UPDATE;
            Row row = field.getRow(sm, store, rm, action);
            if (row != null && !field.isBiMTo1JT()) {
                field.setForeignKey(row, rel);
                // this is for bi-directional maps, the key and value of the
                // map are stored in the table of the mapped-by entity 
                setMapKey(sm, rel, store, row);
            }
           
            if (field.isBiMTo1JT()) { // also need to update the join table
                PersistenceCapable invPC = (PersistenceCapable)sm.fetchObject(
                    field.getBi_1ToM_JTField().getIndex());
                Row secondaryRow = null;
                if (invPC != null) {
                    secondaryRow = rm.getSecondaryRow(field.getBi1ToMJoinFK().getTable(),
                        Row.ACTION_INSERT);
                    secondaryRow.setForeignKey(field.getBi1ToMElemFK(), null, sm);
                    secondaryRow.setForeignKey(field.getBi1ToMJoinFK(), null,
                        RelationStrategies.getStateManager(invPC,
                        store.getContext()));
                    rm.flushSecondaryRow(secondaryRow);
                }
            }
View Full Code Here

            if (rel != null) {
                ForeignKey fk = field.getForeignKey((ClassMapping)
                    rel.getMetaData());
                if (fk.getDeleteAction() == ForeignKey.ACTION_RESTRICT ||
                    fk.getDeleteAction() == ForeignKey.ACTION_CASCADE) {
                    Row row = field.getRow(sm, store, rm, Row.ACTION_DELETE);
                    row.setForeignKey(fk, null, rel);
                    // this is for bi-directional maps, the key and value of the
                    // map are stored in the table of the mapped-by entity 
                    setMapKey(sm, rel, store, row);
                }
            }
View Full Code Here

            return;

        // null inverse if not already enforced by fk
        if (field.getIndependentTypeMappings().length != 1)
            throw RelationStrategies.uninversable(field);
        Row row = rm.getAllRows(fk.getTable(), Row.ACTION_UPDATE);
        row.setForeignKey(fk, io, null);
        row.whereForeignKey(fk, sm);
        rm.flushAllRows(row);
    }
View Full Code Here

        if (field.getIndependentTypeMappings().length != 1)
            throw RelationStrategies.uninversable(field);

        // get the row for the inverse object; the row might be in a secondary
        // table if there is a field controlling the foreign key
        Row row = null;
        FieldMapping[] invs = field.getInverseMappings();
        for (int i = 0; i < invs.length; i++) {
            if (invs[i].getMappedByMetaData() == field
                && invs[i].getTypeCode() == JavaTypes.PC) {
                row = invs[i].getRow(rel, store, rm, action);
                break;
            }
        }
        ClassMapping relMapping = field.getTypeMapping();
        if (row == null)
            row = rm.getRow(relMapping.getTable(), action, rel, true);

        // if this is an update, this might be the only mod to the row, so
        // make sure the where condition is set
        if (action == Row.ACTION_UPDATE
            && row.getTable() == relMapping.getTable())
            row.wherePrimaryKey(rel);

        // update the inverse pointer with our oid value
        row.setForeignKey(fk, io, sm);
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.sql.Row

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.