Examples of FieldMapping

Note that a Filter with the pattern '*' no constraint and only an null value as mapping would create a 1:1 copy of the source. TODO: Is it OK to keep an actual implementation in the Service API package? @author Rupert Westenthaler
  • org.exolab.castor.mapping.xml.FieldMapping
    @version $Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:35 $
  • org.kitesdk.data.FieldMapping
    Represents how to store a Schema field. @since 0.14.0

  • Examples of org.apache.openjpa.jdbc.meta.FieldMapping

        }

        private void setMappedBy(Object oid, OpenJPAStateManager sm, Object coll,
            Result res) {
            // for inverseEager field
            FieldMapping mappedByFieldMapping = field.getMappedByMapping();
            PersistenceCapable mappedByValue = null;
           
            if (mappedByFieldMapping != null) {
                ValueMapping val = mappedByFieldMapping.getValueMapping();
                ClassMetaData decMeta = val.getTypeMetaData();
                // this inverse field does not have corresponding classMapping
                // its value may be a collection/map etc.
                if (decMeta == null)
                    return;
             
                StateManagerImpl owner = ((StateManagerImpl)sm).getObjectIdOwner();
                if (oid.equals(owner.getObjectId())) {
                    mappedByValue = owner.getPersistenceCapable();
                    res.setMappedByFieldMapping(mappedByFieldMapping);
                    res.setMappedByValue(mappedByValue);
                } else if (coll instanceof Collection &&
                    ((Collection) coll).size() > 0) {
                    // Customer (1) <--> Orders(n)
                    // coll contains the values of the toMany field (Orders)
                    // get the StateManager of this toMany value
                    // and find the value of the inverse mappedBy field (Customer)
                    // for this toMacdny field
                    PersistenceCapable pc = (PersistenceCapable)
                        ((Collection) coll).iterator().next();
                    OpenJPAStateManager sm1 = (OpenJPAStateManager) pc.
                        pcGetStateManager();
                   
                    ClassMapping clm = ((ClassMapping) sm1.getMetaData());
                    FieldMapping fm = (FieldMapping) clm.getField(
                        mappedByFieldMapping.getName());
                    if (fm == mappedByFieldMapping)
                        res.setMappedByValue(sm1.fetchObject(fm.getIndex()));
                } else {
                    res.setMappedByValue(null);
                }
            }       
        }
    View Full Code Here

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

            Object oid = sm.getObjectId();
            if (!RelationStrategies.isRelationId(fk)) {
                return oid;
            }
           
            FieldMapping owningField = field.getMappedByMapping();
            if (owningField != null && owningField.getHandler() instanceof RelationId) {
                return ((RelationId)owningField.getHandler()).toRelationDataStoreValue(sm, null);
            }
            if (oid instanceof OpenJPAId) {
                return ((OpenJPAId)oid).getIdObject();
            }
            return oid;
    View Full Code Here

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

        /**
         * Parse collectionTable.
         */
        private boolean startCollectionTable(Attributes attrs)
            throws SAXException {
            FieldMapping fm = (FieldMapping) peekElement();

            FieldMappingInfo info = fm.getMappingInfo();
            DBIdentifier ctbl = parseCollectionTable(attrs);
            info.setTableIdentifier(ctbl);
            return true;
        }
    View Full Code Here

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

        protected boolean startOrderColumn(Attributes attrs)
            throws SAXException {
            Column col = parseOrderColumn(attrs);
            Object obj = peekElement();
            if (obj instanceof FieldMapping) {
                FieldMapping fm = (FieldMapping)obj;
                fm.getMappingInfo().setOrderColumn(col);

            }
            return true;
        }
    View Full Code Here

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

                _deferredMappings.get(cls);
            if (defMappings == null)
                return;
           
            for (DeferredEmbeddableOverrides defMap : defMappings) {
                FieldMapping fm = (FieldMapping)defMap._fm;
                if (defMap == null)
                    return;
                fm = getAttributeOverrideForEmbeddable(fm, defMap._attrName, true);
                // Apply column, table, and unique overrides
                if (defMap._defCols != null) {
                    fm.getValueInfo().setColumns(defMap._defCols);
                    if (!DBIdentifier.isNull(defMap._defTable))
                        fm.getMappingInfo().setTableIdentifier(defMap._defTable);
                    setUnique(fm, defMap._unique);
                }
                // Apply Join column and element join columns overrides overrides
                if (defMap._defJoinCols != null)
                    fm.getMappingInfo().setColumns(defMap._defJoinCols);
                if (defMap._defElemJoinCols != null)
                    fm.getElementMapping().getValueInfo().setColumns(
                        defMap._defElemJoinCols);
            }
            // Clean up after applying mappings
            defMappings.clear();
            _deferredMappings.remove(cls);
    View Full Code Here

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

        }
       
        private boolean startIndex(Attributes attrs)
            throws SAXException {
           
            FieldMapping fm = (FieldMapping) peekElement();
           
            parseIndex(fm.getValueInfo(),
                attrs.getValue("name"),
                Boolean.parseBoolean(attrs.getValue("enabled")),
                Boolean.parseBoolean(attrs.getValue("unique")));
           
            return true;
    View Full Code Here

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

                throw new InternalException();
            }
           
            boolean implicit = Boolean.parseBoolean(_foreignKeyAttributes.getValue("implicit"));
           
            FieldMapping fm = (FieldMapping) peekElement();
            MappingInfo info = fm.getValueInfo();
           
            String name = _foreignKeyAttributes.getValue("name");
            boolean enabled = Boolean.parseBoolean(_foreignKeyAttributes.getValue("enabled"));
            boolean deferred = Boolean.parseBoolean(_foreignKeyAttributes.getValue("deferred"));
            boolean specified = Boolean.parseBoolean(_foreignKeyAttributes.getValue("specified"));
    View Full Code Here

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

        @Override
        protected void parseEagerFetchModeAttr(FieldMetaData fmd, Attributes attrs)
            throws SAXException {
           
            FieldMapping fm = (FieldMapping) fmd;
            String eagerFetchMode = attrs.getValue("eager-fetch-mode");
            if (!StringUtils.isEmpty(eagerFetchMode)) {
                if (eagerFetchMode.equalsIgnoreCase("NONE")) {
                    fm.setEagerFetchMode(EagerFetchModes.EAGER_NONE);
                } else if (eagerFetchMode.equalsIgnoreCase("JOIN")) {
                    fm.setEagerFetchMode(EagerFetchModes.EAGER_JOIN);
                } else if (eagerFetchMode.equalsIgnoreCase("PARALLEL")) {
                    fm.setEagerFetchMode(EagerFetchModes.EAGER_PARALLEL);
                }
            }
        }
    View Full Code Here

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

        protected void parseElementClassCriteriaAttr(FieldMetaData fmd, Attributes attrs)
            throws SAXException {
           
            String elementClassCriteriaString = attrs.getValue("element-class-criteria");
            if (!StringUtils.isEmpty(elementClassCriteriaString)) {
                FieldMapping fm = (FieldMapping) fmd;
                boolean elementClassCriteria = Boolean.parseBoolean(elementClassCriteriaString);
                fm.getElementMapping().getValueInfo().setUseClassCriteria(elementClassCriteria);
            }
        }
    View Full Code Here

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

            ClassMapping owner;
            ClassMapping from, to;
            Action action;
            Variable var;
            Iterator itr = (_actions == null) ? null : _actions.iterator();
            FieldMapping field = null;
            Action prevaction = null;
            boolean isCorrelatedPath = false;
            boolean fromParentRootInSubselect = navigateFromParentRootInSubselect(sel);
                   
            while (itr != null && itr.hasNext()) {
                action = (Action) itr.next();

                // treat subqueries like variables for alias generation purposes
                if (action.op == Action.VAR) {
                    if (sel.getParent() != null && action.var != null &&
                        prevaction != null && prevaction.data != null &&
                        sel.ctx().getVariable(action.var) == null) {
                        isCorrelatedPath = true;
                        pstate.joins = pstate.joins.setCorrelatedVariable(action.var);
                    } else
                        pstate.joins = pstate.joins.setVariable((String) action.data);
                }
                else if (action.op == Action.SUBQUERY) {
                    pstate.joins = pstate.joins.setSubselect((String) action.data);
                }
                else if (action.op == Action.UNBOUND_VAR) {
                    // unbound vars are cross-joined to the candidate table
                    var = (Variable) action.data;
                    rel = (ClassMapping) var.getMetaData();
                    if (rel == null)
                      throw new IllegalArgumentException(_loc.get(
                          "invalid-unbound-var", var.getName()).toString());
                         
                    if (sel.getParent() != null && action.var != null &&
                        sel.ctx().getVariable(action.var) == null) {
                        //System.out.println("Correlated action var="+action.var);
                        isCorrelatedPath = true;
                        pstate.joins = pstate.joins.setCorrelatedVariable(var.getName());
                    } else                
                        pstate.joins = pstate.joins.setVariable(var.getName());

                    pstate.joins = pstate.joins.crossJoin(_candidate.getTable(),
                        rel.getTable());
                    if (!itr.hasNext() && isVariable()) {
                        checkObjectPathInheritanceTypeJoined(pstate);
                    }
                } else {
                    // move past the previous field, if any
                    field = (FieldMapping) ((action.op == Action.GET_XPATH) ?
                        _xmlfield : action.data);

                    if (pstate.field != null) {
                        // if this is the second-to-last field and the last is
                        // the related field this field joins to, no need to
                        // traverse: just use this field's fk columns
                        if (!itr.hasNext() && (flags & JOIN_REL) == 0
                            && isJoinedField(pstate.field, key, field)) {
                            pstate.cmpfield = field;
                            break;
                        }
                       
                        if (fromParentRootInSubselect) {
                            isCorrelatedPath = true;
                            pstate.joins = pstate.joins.setCorrelatedVariable(_schemaAlias);
                            pstate.joins.setJoinContext(null);
                        }
                       
                        rel = traverseField(pstate, key, forceOuter ||
                                  ctx.store.getDBDictionary().fullResultCollectionInOrderByRelation, false);
                    }

                    // mark if the next traversal should go through
                    // the key rather than value
                    key = action.op == Action.GET_KEY;
                    forceOuter |= action.op == Action.GET_OUTER;
                   
                    if (key && itr.hasNext())
                        _keyPath = true;

                    // get mapping for the current field
                    pstate.field = field;

                    owner = pstate.field.getDefiningMapping();
                    if (pstate.field.getManagement()
                        != FieldMapping.MANAGE_PERSISTENT)
                        throw new UserException(_loc.get("non-pers-field",
                            pstate.field));

                    // find the most-derived type between the declared relation
                    // type and the field's owner, and join from that type to
                    // the lesser derived type
                    if (rel != owner && rel != null) {
                        if (rel.getDescribedType().isAssignableFrom
                            (owner.getDescribedType())) {
                            from = owner;
                            to = rel;
                        } else {
                            from = rel;
                            to = owner;
                        }

                        for (; from != null && from != to;
                            from = from.getJoinablePCSuperclassMapping()) {
                          FieldMapping cast = from.getFieldMapping(pstate.field
                              .getName());
                          if (cast != null)
                            pstate.field = cast;
                            pstate.joins = from.joinSuperclass(pstate.joins, false);
                        }
    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.