Examples of ValueMapping


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

        // for inverseEager field
        FieldMapping mappedByFieldMapping = field.getMappedByMapping();
        PersistenceCapable mappedByValue = null;

        if (mappedByFieldMapping != null) {
          ValueMapping val = mappedByFieldMapping.getValueMapping();
          ClassMetaData decMeta = val.getTypeMetaData();
            // eager loading a child from its toOne parent and
            // the parent has @OneToOne(mappedBy="parent") child relation.
            // By saving the mapped-by info in 'res' is to
            // avoid unneeded SQL pushdown that would otherwise gets
            // generated.
View Full Code Here

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

        return getAttributeOverrideField(attrName, fm, embed);
    }

    public static Class<?> getEmbeddedClassType(FieldMapping fm,
        String attrName) {
        ValueMapping embed = null;
        boolean isKey = false;
        boolean isValue = false;
        if (attrName != null && attrName.startsWith("key."))
            isKey = true;
        else if (attrName != null && attrName.startsWith("value."))
            isValue = true;
        if (isKey || isValue)
            attrName = attrName.substring(attrName.indexOf(".")+1);
           
        int typeCode = fm.getValue().getDeclaredTypeCode();
        switch (typeCode) {
            case JavaTypes.COLLECTION : // a collection of embeddables
                if (isKey || isValue)
                    throw new MetaDataException(_loc.get("embed-override-name",
                        fm, attrName));
                embed = fm.getElementMapping();
                break;
            case JavaTypes.MAP: // a map
                if (!isKey && !isValue)
                    throw new MetaDataException(_loc.get("embed-override-name",
                        fm, attrName));
                if (isKey)
                    embed = fm.getKeyMapping();
                else if (isValue)    
                    embed = fm.getElementMapping();
                break;
            default: // an embeddable
                if (isKey || isValue)
                    throw new MetaDataException(_loc.get("embed-override-name",
                        fm, attrName));
                embed = fm.getValueMapping();
                break;
        }
       
        if (embed == null) {
            throw new MetaDataException(_loc.get("not-embedded", fm));
        }
        return embed.getDeclaredType();
    }
View Full Code Here

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

     * given columns.
     */
    private void where(Object oid, ClassMapping mapping, Column[] toCols,
        Column[] fromCols, Object[] vals, Column[] constCols, PathJoins pj,
        JDBCStore store) {
        ValueMapping embed = mapping.getEmbeddingMapping();
        if (embed != null) {
            where(oid, embed.getFieldMapping().getDefiningMapping(),
                toCols, fromCols, vals, constCols, pj, store);
            return;
        }

        // only bother to pack pk values into array if app id
View Full Code Here

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

    public void testNonpolymorphic() {
        FieldMapping fm = _mapping.getFieldMapping("superRel");
        assertEquals(ValueMapping.POLY_FALSE, fm.getPolymorphic());

        ValueMapping vm = _mapping.getFieldMapping("joinCollection").
            getElementMapping();
        assertEquals(ValueMapping.POLY_JOINABLE, vm.getPolymorphic());

        vm = _mapping.getFieldMapping("joinMap").getKeyMapping();
        assertEquals(ValueMapping.POLY_FALSE, vm.getPolymorphic());
        vm = _mapping.getFieldMapping("joinMap").getElementMapping();
        assertEquals(ValueMapping.POLY_FALSE, vm.getPolymorphic());
    }
View Full Code Here

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

        return super.getJoinForeignKey(cls);
    }

    public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
        JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
        ValueMapping vm = field.getKeyMapping();
        if (vm.isEmbedded())
            sel.select(key, field.getKeyMapping().getSelectSubclasses(),
                store, fetch, JDBCFetchConfiguration.EAGER_NONE, joins);
        else
            throw new InternalException();
    }
View Full Code Here

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

    }

    public Object loadKey(OpenJPAStateManager sm, JDBCStore store,
        JDBCFetchConfiguration fetch, Result res, Joins joins)
        throws SQLException {
        ValueMapping vm = field.getKeyMapping();
        if (vm.isEmbedded())
            return vm.getValueMappedByMapping().
                loadProjection(store, fetch, res, joins);
        else
            throw new InternalException();
    }
View Full Code Here

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

    public Result[] getResults(final OpenJPAStateManager sm,
        final JDBCStore store, final JDBCFetchConfiguration fetch,
        final int eagerMode, final Joins[] joins, boolean lrs)
        throws SQLException {
        ValueMapping val = field.getElementMapping();
        final ClassMapping[] vals = val.getIndependentTypeMappings();
        Union union = store.getSQLFactory().newUnion(vals.length);
        if (fetch.getSubclassFetchMode(val.getTypeMapping())
            != JDBCFetchConfiguration.EAGER_JOIN)
            union.abortUnion();
        union.setLRS(lrs);
        union.select(new Union.Selector() {
            public void select(Select sel, int idx) {
View Full Code Here

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

        return joins;
    }

    public Joins joinKeyRelation(Joins joins, boolean forceOuter,
        boolean traverse) {
        ValueMapping key = field.getKeyMapping();
        if (key.isEmbedded())
            return joins;

        ClassMapping[] clss = key.getIndependentTypeMappings();
        if (clss.length != 1) {
            if (traverse)
                throw RelationStrategies.unjoinable(key);
            return joins;
        }
        if (forceOuter)
            return joins.outerJoinRelation(field.getName(),
                key.getForeignKey(clss[0]), clss[0], key.getSelectSubclasses(),
                false, false);
        return joins.joinRelation(field.getName(),
            key.getForeignKey(clss[0]), clss[0], key.getSelectSubclasses(),
            false, false);
    }
View Full Code Here

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

                // warn the user about making the collection side the owner
                Log log = field.getRepository().getLog();
                if (log.isInfoEnabled())
                    log.info(_loc.get("coll-owner", field, mapped));
                ValueMapping elem = mapped.getElementMapping();
                ForeignKey fk = elem.getForeignKey();
                field.setJoinForeignKey(fk);
                field.getElementMapping().setForeignKey(
                        mapped.getJoinForeignKey());
            } else
                throw new MetaDataException(_loc.get("not-inv-relation",
                    field, mapped));

            field.setUseClassCriteria(criteria);
            return;
        } else {
            // Uni-/OneToMany/ForeingKey
            ValueMapping val = field.getElementMapping();
            val.getValueInfo().setColumns(field.getValueInfo().getColumns());
            if (val.getTypeMapping().isMapped()) {
                ValueMappingInfo vinfo = val.getValueInfo();
                ForeignKey fk = vinfo.getTypeJoin(val, DBIdentifier.NULL, false, adapt);
                val.setForeignKey(fk);
                val.setColumnIO(vinfo.getColumnIO());
            } else
                RelationStrategies.mapRelationToUnmappedPC(val, "value", adapt);

            val.mapConstraints("value", adapt);
           
            return;
        }
/*
        // this is necessary to support openjpa 3 mappings, which didn't
View Full Code Here

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

                        (HandlerRelationMapTableFieldStrategy) strat;
                    hrStrat.setKey(keyObj, store, newRow);
                } else if (keyObj instanceof PersistenceCapable) {
                    OpenJPAStateManager keysm =
                        RelationStrategies.getStateManager(entry.getKey(), ctx);
                    ValueMapping key = fm.getKeyMapping();
                    if (keysm != null)
                        key.setForeignKey(newRow, keysm);
                    else
                        key.setForeignKey(newRow, null);
                }
                rm.flushSecondaryRow(newRow);
                found = true;
            }
        }
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.