Package org.apache.openjpa.jdbc.sql

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


            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

     */
    public void deleteRow(OpenJPAStateManager sm, JDBCStore store,
        RowManager rm)
        throws SQLException {
        if (_fk != null) {
            Row row = rm.getRow(getTable(), Row.ACTION_DELETE, sm, true);
            row.whereForeignKey(_fk, sm);
        }
    }
View Full Code Here

     * Utility method for use by mapping strategies.
     */
    public Row getRow(OpenJPAStateManager sm, JDBCStore store, RowManager rm,
        int action)
        throws SQLException {
        Row row = null;
        boolean newOuterRow = false;
        if (_fk != null && _outer && action != Row.ACTION_DELETE) {
            // if updating with outer join, delete old value first, then insert;
            // we can't just update b/c the row might not exist
            if (action == Row.ACTION_UPDATE) {
                // maybe some other field already is updating?
                row = rm.getRow(getTable(), Row.ACTION_UPDATE, sm, false);
                if (row == null) {
                    Row del = rm.getRow(getTable(), Row.ACTION_DELETE, sm,
                        true);
                    del.whereForeignKey(_fk, sm);
                }
            } else
                row = rm.getRow(getTable(), Row.ACTION_INSERT, sm, false);

            // only update/insert if the row exists already or the value is
View Full Code Here

        ValueMapping elem = field.getElementMapping();
        ColumnIO io = elem.getColumnIO();
        ForeignKey fk = elem.getForeignKey();
        if (!elem.getUseClassCriteria() && io.isAnyUpdatable(fk, true)) {
            assertInversable();
            Row row = rm.getAllRows(fk.getTable(), Row.ACTION_UPDATE);
            row.setForeignKey(fk, io, null);
            row.whereForeignKey(fk, sm);
            rm.flushAllRows(row);
            return;
        }

        if (!sm.getLoaded().get(field.getIndex()))
View Full Code Here

        assertInversable();

        // if this is an update, this might be the only mod to the row, so
        // make sure the where condition is set
        Row row = rm.getRow(fk.getTable(), action, invsm, true);
        if (action == Row.ACTION_UPDATE)
            row.wherePrimaryKey(invsm);

        // update the inverse pointer with our oid value
        if (writeable)
            row.setForeignKey(fk, io, sm);
        if (orderWriteable)
            row.setInt(order, idx);
    }
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

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.