Package org.apache.openjpa.jdbc.meta

Examples of org.apache.openjpa.jdbc.meta.ClassMapping


        if (!sel && asc == null)
            return 0;

        // if this mapping can't select the full pk values, then join to
        // super and recurse
        ClassMapping sup;
        if (!mapping.isPrimaryKeyObjectId(true)) {
            sup = mapping.getJoinablePCSuperclassMapping();
            if (joins == null)
                joins = newJoins();
            joins = mapping.joinSuperclass(joins, false);
            return primaryKeyOperation(sup, sel, asc, joins, aliasOrder);
        }

        Column[] cols = mapping.getPrimaryKeyColumns();
        if (isGrouping()) {
            groupBy(cols, joins);
            return 0;
        }

        PathJoins pj = getJoins(joins, false);
        int seld = 0;
        for (int i = 0; i < cols.length; i++)
            if (columnOperation(cols[i], sel, asc, pj, aliasOrder))
                seld |= 2 << i;

        // if this mapping has not been used in the select yet (and therefore
        // is not joined to anything), but has an other-table superclass that
        // has been used, make sure to join to it
        boolean joined = false;
        for (sup = mapping.getJoinablePCSuperclassMapping(); sup != null;
            mapping = sup, sup = mapping.getJoinablePCSuperclassMapping()) {
            if (sup.getTable() == mapping.getTable())
                continue;

            if (mapping.getTable() != sup.getTable()
                && getTableIndex(mapping.getTable(), pj, false) == -1
                && getTableIndex(sup.getTable(), pj, false) != -1) {
                if (pj == null)
                    pj = (PathJoins) newJoins();
                pj = (PathJoins) mapping.joinSuperclass(pj, false);
                joined = true;
            } else
View Full Code Here


    private void wherePrimaryKey(Object oid, ClassMapping mapping, Joins joins,
        JDBCStore store) {
        // if this mapping's identifiers include something other than
        // the pk values, join to super and recurse
        if (!mapping.isPrimaryKeyObjectId(false)) {
            ClassMapping sup = mapping.getJoinablePCSuperclassMapping();
            if (joins == null)
                joins = newJoins();
            joins = mapping.joinSuperclass(joins, false);
            wherePrimaryKey(oid, sup, joins, store);
            return;
View Full Code Here

    }

    protected Object loadElement(OpenJPAStateManager sm, JDBCStore store,
        JDBCFetchConfiguration fetch, Result res, Joins joins)
        throws SQLException {
        ClassMapping elem = res.getBaseMapping();
        if (elem == null)
            elem = field.getElementMapping().getIndependentTypeMappings()[0];
        return res.load(elem, store, fetch, joins);
    }
View Full Code Here

    }

    protected Joins join(Joins joins, ClassMapping elem) {
        ValueMapping vm = field.getElementMapping();
        ForeignKey fk = vm.getForeignKey(elem);
        ClassMapping owner = field.getDefiningMapping();
        while (fk.getPrimaryKeyTable() != owner.getTable()) {
            joins = owner.joinSuperclass(joins, false);
            owner = owner.getJoinablePCSuperclassMapping();
            if (owner == null)
                throw new InternalException();
        }
        return joins.joinRelation(field.getName(), fk, elem,
            vm.getSelectSubclasses(), true, true);
View Full Code Here

            return;
        Collection coll = toCollection(vals);
        if (coll == null || coll.isEmpty())
            return;

        ClassMapping rel = field.getElementMapping().getTypeMapping();
        int idx = 0;
        for (Iterator itr = coll.iterator(); itr.hasNext(); idx++)
            updateInverse(sm.getContext(), itr.next(), rel, rm, sm, idx);
    }
View Full Code Here

            return;
        }

        // null inverse columns for deletes and update them with our oid for
        // inserts
        ClassMapping rel = field.getElementMapping().getTypeMapping();
        StoreContext ctx = store.getContext();
        if (field.getMappedBy() == null) {
            Collection rem = ct.getRemoved();
            for (Iterator itr = rem.iterator(); itr.hasNext();)
                updateInverse(ctx, itr.next(), rel, rm, null, 0);
View Full Code Here

        if (!sm.getLoaded().get(field.getIndex()))
            return;

        // update fk on each field value row
        ClassMapping rel = field.getElementMapping().getTypeMapping();
        StoreContext ctx = store.getContext();
        Collection objs = toCollection(sm.fetchObject(field.getIndex()));
        if (objs != null && !objs.isEmpty())
            for (Iterator itr = objs.iterator(); itr.hasNext();)
                updateInverse (ctx, itr.next(), rel, rm, sm, 0);
View Full Code Here

        if (orderWriteable)
            row.setInt(order, idx);
    }

    public Object toDataStoreValue(Object val, JDBCStore store) {
        ClassMapping cm = field.getElementMapping().getTypeMapping();
        return cm.toDataStoreValue(val, cm.getPrimaryKeyColumns(), store);
    }
View Full Code Here

    /**
     * Return whether our defining mapping is an unjoined subclass of
     * the type of the given value.
     */
    private boolean isTypeUnjoinedSubclass(ValueMapping mapped) {
        ClassMapping def = field.getDefiningMapping();
        for (; def != null; def = def.getJoinablePCSuperclassMapping())
            if (def == mapped.getTypeMapping())
                return false;
        return true;
    }
View Full Code Here

                && 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.meta.ClassMapping

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.