Package org.apache.openjpa.meta

Examples of org.apache.openjpa.meta.ClassMetaData


        //  for inverse toOne relation field
        FieldMapping mappedByFieldMapping = field.getMappedByMapping();
       
        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;
           
View Full Code Here


        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;
         
View Full Code Here

        getPersistentTypeNames(false, envLoader);
        URL xml = findXML(cls);

        // we have to parse metadata up-front to register persistence unit
        // defaults and system callbacks
        ClassMetaData meta;
        boolean parsedXML = false;
        if (_unparsed != null && !_unparsed.isEmpty()
            && (mode & MODE_META) != 0) {
            Set<URL> unparsed = new HashSet<URL>(_unparsed);
            for (URL url : unparsed) {
                parseXML(url, cls, mode, envLoader);
            }
            parsedXML = unparsed.contains(xml);
             _unparsed.clear();

            // XML process check
            meta = repos.getCachedMetaData(cls);
            if (meta != null && (meta.getSourceMode() & mode) == mode) {
                validateStrategies(meta);
                return;
            }
        }

        // might have been looking for system-level query
        if (cls == null)
            return;

        // we may still need to parse XML if this is a redeploy of a class, or
        // if we're in strict query-only mode
        if (!parsedXML && xml != null) {
            parseXML(xml, cls, mode, envLoader);
            // XML process check
            meta = repos.getCachedMetaData(cls);
            if (meta != null && (meta.getSourceMode() & mode) == mode) {
                validateStrategies(meta);
                return;
            }
        }

        AnnotationPersistenceMetaDataParser parser = getAnnotationParser();
        parser.setEnvClassLoader(envLoader);
        parser.setMode(mode);
        parser.parse(cls);

        meta = repos.getCachedMetaData(cls);
        if (meta != null && (meta.getSourceMode() & mode) == mode)
            validateStrategies(meta);
    }
View Full Code Here

                sm.getMetaData()));
        }
    }
   
    private Object getPKValue(StateManagerImpl pkSm) {
        ClassMetaData pkMeta = pkSm.getMetaData();
        FieldMetaData[] fmds = pkMeta.getPrimaryKeyFields();
        // MappedById is for single value primary key or embeddable id
        if (fmds.length == 0)
            return null;
        else
            return ApplicationIds.getKey(pkSm.getObjectId(), pkMeta);
View Full Code Here

    protected File defaultSourceFile(ClassMetaData meta) {
        return defaultXMLFile();
    }

    protected File defaultSourceFile(QueryMetaData query, Map clsNames) {
        ClassMetaData meta = getDefiningMetaData(query, clsNames);
        File file = (meta == null) ? null : meta.getSourceFile();
        if (file != null)
            return file;
        return defaultXMLFile();
    }
View Full Code Here

        else
            return ApplicationIds.getKey(pkSm.getObjectId(), pkMeta);
    }
   
    private void setPKValue(StateManagerImpl sm, Object pkVal) {
        ClassMetaData meta = sm.getMetaData();
        FieldMetaData[] fmds = meta.getPrimaryKeyFields();
        if (fmds.length == 0)
            return;

        Strategy strat = ((FieldMapping)fmds[0]).getStrategy();
        // single value primary key
View Full Code Here

      Class<?> sup = cls.getSuperclass();
      if (sup == null || "java.lang.Object".equals(
          sup.getName()))
        return null;
      MetaDataRepository repos = meta.getRepository();
      ClassMetaData supMeta = repos.getCachedMetaData(sup);
      if (supMeta == null)
        supMeta = repos.getMetaData(sup, null, false);
      return supMeta;
    }
View Full Code Here

      access = determineImplicitAccessType(meta.getDescribedType(),
                  meta.getRepository().getConfiguration());
      if (!AccessCode.isUnknown(access))
        return access;
     
      ClassMetaData sup = getCachedSuperclassMetaData(meta);
      ClassMetaData tmpSup = sup;
      while (tmpSup != null && tmpSup.isExplicitAccess()) {
            tmpSup = getCachedSuperclassMetaData(tmpSup);
            if (tmpSup != null) {
                sup = tmpSup;
            }         
      }
View Full Code Here

        // correct id type for the specified class; this is for cases
        // when we have an application id hierarchy and we had set the
        // metadata to a superclass id -- the subclass' id may be a
        // different class, so we need to reset it
        if (_meta.getDescribedType() != cls) {
            ClassMetaData sub = _meta.getRepository().getMetaData
                (cls, _broker.getClassLoader(), true);
            if (_oid != null) {
                if (_meta.getIdentityType() == ClassMetaData.ID_DATASTORE)
                    _oid = _broker.getStoreManager().copyDataStoreId(_oid,
                        sub);
                else if (_meta.isOpenJPAIdentity())
                    _oid = ApplicationIds.copy(_oid, sub);
                else if (sub.getObjectIdType() != _meta.getObjectIdType()) {
                    Object[] pkFields = ApplicationIds.toPKValues(_oid, _meta);
                    _oid = ApplicationIds.fromPKValues(pkFields, sub);
                }
            }
            _meta = sub;
View Full Code Here

        FieldMetaData fmd = _meta.getField(field);
        Object pk = ApplicationIds.get(oid, fmd);
        if (pk == null)
            return null;

        ClassMetaData relmeta = fmd.getDeclaredTypeMetaData();
        pk = ApplicationIds.wrap(relmeta, pk);
        if (relmeta.getIdentityType() == ClassMetaData.ID_DATASTORE
            && fmd.getObjectIdFieldTypeCode() == JavaTypes.LONG)
            pk = _broker.getStoreManager().newDataStoreId(pk, relmeta);
        else if (relmeta.getIdentityType() == ClassMetaData.ID_APPLICATION
            && fmd.getObjectIdFieldType() != relmeta.getObjectIdType())
            pk = ApplicationIds.fromPKValues(new Object[] { pk }, relmeta);
        return _broker.find(pk, false, null);
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.meta.ClassMetaData

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.