Package com.sun.jdo.api.persistence.model.mapping

Examples of com.sun.jdo.api.persistence.model.mapping.MappingClassElement


        String className = pcClass.getName();
        ClassLoader classLoader = pcClass.getClassLoader();
        ClassDesc rc = null;

        try {
            MappingClassElement mdConfig =
               model.getMappingClass(className, classLoader);

            // Validate the model information for this class.
            validateModel(model, className, classLoader);
View Full Code Here


   * @see MappingClassElementImpl#forName
   */
  public MappingClassElement getMappingClass (String className,
    ClassLoader classLoader)
  {
    MappingClassElement mappingClass = null;

    // First check class loader. This has to be done before the super call!
    // Method Model.getMappingClass will check the MappingClassElement cache
    // and will find an entry in the case of a multiple class loader for the
    // same class name. So we have to check the multiple class loader first.
    classLoader = findClassLoader(className, classLoader);
    mappingClass = super.getMappingClass(className, classLoader);
    if ((mappingClass != null) && (classLoader != null))
    {
      // Lookup the SchemElement connected to mappingClass. This reads
      // the .dbschema file using the specified classLoader and stores the
      // SchemaElement in the SchemaElement cache. Any subsequent
      // SchemaElement.forName or TableElement.forName lookups will use
      // the cached version.
      String databaseRoot = mappingClass.getDatabaseRoot();

      // An unmapped mapping class is allowed in which case the
      // databaseRoot will be null (never mapped) or empty
      // (mapped once, unmapped now), but if the databaseRoot is
      // not null or empty and we can't find the schema, throw a
View Full Code Here

    // the first in the cache.
    // Any other access of _classes potentially needs to be synchronized
    // using the same variable _classes (e.g. updateKeyForClass).
    synchronized (this._classes)
    {
      MappingClassElement mappingClass =
        (MappingClassElement)_classes.get(className);

      if (mappingClass == null)
      {
        // check whether the class is known to be non PC
        if (_nonPCClasses.contains(className))
          return null;

        try
        {
          InputStream stream = getInputStreamForResource(className,
            classLoader, getResourceNameWithExtension(className));

          if (stream != null)
          {
            // if the file is empty, the archiver prints an
            // exception, so protect against that case and
            // return null without updating either cache
            if (stream.available() > 0)
            {
              XMLInputStream xmlInput = new XMLInputStream(stream,
                getClass().getClassLoader());

              mappingClass =
                (MappingClassElement)xmlInput.readObject();
              xmlInput.close();

              // postUnarchive performs version number checking
              // and possible format conversions
              mappingClass.postUnarchive();

              // can't call updateKeyForClass here there are cases
              // when the mapping class name doesn't match the
              // classname (such as copy/paste, move etc.)
              _classes.put(className, mappingClass);

              // update the modified flags for the mapping and
              // persistence classes since the xml archiver uses
              // all the set methods
              mappingClass.setModified(false);
              getPersistenceClass(mappingClass).
                setModified(false);
            }
          }
          else
View Full Code Here

    synchronized (this._classes)
    {
      for (Iterator i = classNames.iterator(); i.hasNext();)
      {
        String className = (String)i.next();
        MappingClassElement mapping =
          (MappingClassElement)_classes.get(className);

        // If the cache has a MappingClassElement with the specified
        // className, get its databaseRoot and remove the corresonding
        // SchemaElement from the SchemaElement cache.
        if (mapping != null)
          SchemaElement.removeFromCache(mapping.getDatabaseRoot());
       
        // remove the corresponding MappingClassElement from cache
        _classes.remove(className);
       
        // remove the class from the set of classes known to be non PC
View Full Code Here

   * @exception IOException if there is some error saving the class
   * @see #storeMappingClass
   */
  public void storeMappingClass (String className) throws IOException
  {
    MappingClassElement mappingClass = null;

    synchronized (this._classes)
    {
      mappingClass = (MappingClassElement)_classes.get(className);
    }
View Full Code Here

   * @return <code>true</code> if this field name represents a field in
   * the default fetch group; <code>false</code> otherwise.
   */
  public boolean isDefaultFetchGroup (String className, String fieldName)
  {
    MappingClassElement mappingClass = getMappingClass(className);

    try
    {
      return (MappingFieldElement.GROUP_DEFAULT ==
        mappingClass.getField(fieldName).getFetchGroup());
    }
    catch (Exception e)
    {}  // will return false

    return false;
View Full Code Here

        // Remove generated fields from jdo model and mapping
        // model before returning the result.
        if (skipGeneratedFields) {
            Iterator iter = mappingClasses.iterator();
            while (iter.hasNext()) {
                MappingClassElement mapClassElt = (MappingClassElement)iter.next();
                if (mapClassElt != null) {
                    String className = mapClassElt.getName();
                    String ejbName = nameMapper.getEjbNameForPersistenceClass(
                        className);

                    PersistenceClassElement pce = (PersistenceClassElement)
                            model.getPersistenceClass(className);
                    PersistenceFieldElement[] allFields = pce.getFields();
                    if (allFields != null) {
                        List generatedFieldList = new ArrayList();

                        // In order to avoid concurrentmod exception,
                        // loop through all persistence fields to put generated
                        // fields in a list, loop though the list to remove
                        // the generated fields from the model.
                        for (int i = 0; i < allFields.length; i++) {
                            PersistenceFieldElement pfe = allFields[i];
                            if (pfe != null) {
                                String pFieldName = pfe.getName();
                                String ejbFieldName = nameMapper.
                                    getEjbFieldForPersistenceField(className,
                                    pFieldName);
                                if (nameMapper.isGeneratedField(ejbName,
                                    ejbFieldName)) {
                                    generatedFieldList.add(pfe);
                                }
                            }
                        }

                        // If the field is a version field, don't remove it
                        // from the model even though it is generated because
                        // it is needed to hold the version column information.
                        Iterator iterator = generatedFieldList.iterator();
                        while (iterator.hasNext()) {
                            PersistenceFieldElement pfe =
                                (PersistenceFieldElement)iterator.next();
                            MappingFieldElement mfe = mapClassElt.
                                 getField(pfe.getName());
                            if (mfe != null && (!mfe.isVersion())) {
                                model.removeFieldElement(pfe);
                                mapClassElt.removeField(mfe);
                            }
                        }
                    }
                }
            }
View Full Code Here

     * @param mappingClasses a collection of mapping classes
     */
    private void updateMappingClasses(Collection mappingClasses) {
        Iterator iter = mappingClasses.iterator();
        while (iter.hasNext()) {
            MappingClassElement mapClassElt = (MappingClassElement)iter.next();
            //put it in the models' cache
            model.updateKeyForClass(mapClassElt, null);
            //keep a strong ref
            strongRefs.add(mapClassElt);
        }
View Full Code Here

   
            requireCloneOnGetAndSet = requireCloneOnGetAndSet(type);
            isGeneratedField = nameMapper.isGeneratedField(beanName, name);

            // Check if the field is in DFG.
            MappingClassElement mce = model.getMappingClass(pcname);
            MappingFieldElement mfe = mce.getField(name);
            isDFG = (mfe.getFetchGroup() == MappingFieldElement.GROUP_DEFAULT);
        }
View Full Code Here

            // The mapping class element may be null if there is inconsistency
            // in sun-cmp-mappings.xml and ejb-jar.xml. For example,
            // the bean has mapping information in sun-cmp-mappings.xml but
            // no definition in the ejb-jar.xml.
            // So iterate over the mappings until the 1st non-null is found.
            MappingClassElement mc = null;
            Iterator iter = mappingClasses.values().iterator();
            while (iter.hasNext()) {
                mc = (MappingClassElement)iter.next();
                if (mc != null) {
                    schema = SchemaElement.forName(mc.getDatabaseRoot());
                    break;
                }
            }

            if (logger.isLoggable(Logger.FINE)){
View Full Code Here

TOP

Related Classes of com.sun.jdo.api.persistence.model.mapping.MappingClassElement

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.