Package org.apache.openjpa.jdbc.sql

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


    }

    public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
        throws SQLException {
        if (field.getColumnIO().isUpdatable(0, false)) {
            Row row = field.getRow(sm, store, rm, Row.ACTION_UPDATE);
            if (row != null) {
                Object value = sm.fetch(field.getIndex());
                if (!HandlerStrategies.set(field, value, store, row, _cols,
                    _io, field.getNullValue() == FieldMapping.NULL_NONE))
                    if (field.getValueStrategy() != ValueStrategies.AUTOASSIGN)
                        throw new UserException(_loc.get("cant-set-value", row
                            .getFailedObject(), field, value));
            }
        }
    }
View Full Code Here


    }

    public void where(OpenJPAStateManager sm, JDBCStore store, RowManager rm,
        Object prevValue)
        throws SQLException {
        Row row = field.getRow(sm, store, rm, Row.ACTION_UPDATE);
        if (row != null)
            HandlerStrategies.where(field, prevValue, store, row, _cols);
    }
View Full Code Here

        field.getValueInfo().assertNoSchemaComponents(field, !adapt);
    }
   
    public void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
        throws SQLException {
        Row row = rm.getAllRows(field.getTable(), Row.ACTION_DELETE);
        row.whereForeignKey(field.getJoinForeignKey(), sm);
        rm.flushAllRows(row);
    }
View Full Code Here

        for (Map.Entry entry : entrySets) {
            Object value = entry.getValue();
            if (obj instanceof ReflectingPersistenceCapable)
               obj = ((ReflectingPersistenceCapable)obj).getManagedInstance();
            if (value == obj) {
                Row newRow = (Row) ((RowImpl)row).clone();
                Object keyObj = entry.getKey();
                Strategy strat = fm.getStrategy();
                if (strat instanceof HandlerRelationMapTableFieldStrategy) {
                    HandlerRelationMapTableFieldStrategy hrStrat =
                        (HandlerRelationMapTableFieldStrategy) strat;
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) {
            // set the OrderColumn value
            row.setInt(order, idx);
        }
    }
View Full Code Here

        }
    }

    public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
        throws SQLException {
        Row row = field.getRow(sm, store, rm, Row.ACTION_INSERT);
        if (row == null)
            return;

        OpenJPAStateManager em = store.getContext().getStateManager
            (sm.fetchObject(field.getIndex()));
View Full Code Here

        throws SQLException {
        OpenJPAStateManager em = store.getContext().getStateManager
            (sm.fetchObject(field.getIndex()));
        boolean newVal = em == null || em.getPCState() == PCState.ECOPY;

        Row row = null;
        if (newVal && field.getJoinForeignKey() != null
            && field.isJoinOuter()) {
            // if our record is in an outer-joined related table and we're not
            // updating an existing value, delete the old one
            Row del = rm.getRow(field.getTable(), Row.ACTION_DELETE, sm, true);
            del.whereForeignKey(field.getJoinForeignKey(), sm);
            delete(sm, null, store, rm, del);

            // insert the new value
            row = rm.getRow(field.getTable(), Row.ACTION_INSERT, sm,
                em != null);
View Full Code Here

        throws SQLException {
        OpenJPAStateManager em = null;
        if (sm.getLoaded().get(field.getIndex()))
            em = store.getContext().getStateManager(sm.fetchObject
                (field.getIndex()));
        Row row = field.getRow(sm, store, rm, Row.ACTION_DELETE);
        delete(sm, em, store, rm, row);
    }
View Full Code Here

        // loop through fields and update changing values for the next state
        // image, plus add WHERE conditions on updates to make sure that
        // db values match our previous image
        FieldMapping[] fields = (FieldMapping[]) sm.getMetaData().getFields();
        Row row;
        if (sm.isVersionCheckRequired()) {
            for (int i = 0, max = loaded.length(); i < max; i++) {
                if (!loaded.get(i))
                    continue;

                // update our next state image with the new field value
                if (sm.getDirty().get(i) && !sm.getFlushed().get(i))
                    nextState[i] = sm.fetch(fields[i].getIndex());

                // fetch the row for this field; if no row exists, then we can't
                // add one because we have no updates to perform; that means we
                // won't detect OL exceptions when another transaction changes
                // fields that aren't in any of the same tables as fields that
                // this transaction changed
                row = rm.getRow(fields[i].getTable(), Row.ACTION_UPDATE,
                    sm, false);
                if (row == null)
                    continue;

                // set WHERE criteria matching the previous state image so the
                // update will fail for any changes made by another transaction
                fields[i].where(sm, store, rm, state[i]);
                row.setFailedObject(sm.getManagedInstance());
            }
        }
        sm.setNextVersion(nextState);
    }
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.