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

Examples of com.sun.jdo.api.persistence.model.jdo.PersistenceFieldElement


    private void initializeFields() {
        ArrayList concurrencyGroups = new ArrayList();
        persistentFields = pcElement.getFields();

        for (int i = 0; i < persistentFields.length; i++) {
            PersistenceFieldElement pcf = persistentFields[i];
            MappingFieldElementImpl mdf = (MappingFieldElementImpl) mdConfig.getField(pcf.getName());

            if (mdf == null) {
                throw new JDOFatalUserException(I18NHelper.getMessage(messages,
                        "core.configuration.fieldnotmapped", // NOI18N
                        pcf.getName(), pcElement.getName()));
            }

            FieldDesc f;

            if (!(mdf instanceof MappingRelationshipElement)) {
                f = createLocalField(mdf);
            } else {
                f = createForeignField((RelationshipElement) pcf, (MappingRelationshipElementImpl) mdf);
            }

            initializeFetchAndConcurrencyGroup(f, pcf, mdf, concurrencyGroups);

            if (mdf.isReadOnly()) {
                f.sqlProperties |= FieldDesc.PROP_READ_ONLY;
            }

            try {
                f.setupDesc(pcClass, pcf.getName());
            } catch (JDOException e) {
                throw e;
            } catch (Exception e) {
                throw new JDOFatalInternalException(I18NHelper.getMessage(messages,
                "core.configuration.loadfailed.field", // NOI18N
                pcf.getName(), pcElement.getName()), e);
            }

            f.absoluteID = pcf.getFieldNumber();

            addField(f);

            if (logger.isLoggable(Logger.FINEST)) {
                Object[] items = new Object[] {f.getName(),new Integer(f.absoluteID)};
View Full Code Here


    public boolean isPrimaryKeyField(String classPath, String fieldName)
        throws JDOMetaDataUserException, JDOMetaDataFatalError
    {
        final String className = pathToName(classPath);
        final PersistenceFieldElement pfe
            = model.getPersistenceField(className, fieldName);
        if (pfe != null) {
            return pfe.isKey();
        } else {
            return false;
        }
    }
View Full Code Here

   * @return <code>true</code> if this field name represents a key field;
   * <code>false</code> otherwise.
   */
  public boolean isKey (String className, String fieldName)
  {
    PersistenceFieldElement field =
      getPersistenceField(className, fieldName);

    return field != null ? field.isKey() : false;
  }
View Full Code Here

        throws JDOMetaDataUserException, JDOMetaDataFatalError
    {
        final String className = pathToName(classPath);
        boolean isdfgField = model.isDefaultFetchGroup(className, fieldName);
        if(isdfgField) {
            final PersistenceFieldElement pfe
                = model.getPersistenceField(className, fieldName);
            if (pfe instanceof RelationshipElement) {
                // This is a relationship field. Flag it as not belonging
                // to dfg.
                // Relationship fields are always flaged as not belonging to dfg
View Full Code Here

     */
    public int getFieldNo(String classPath, String fieldName)
        throws JDOMetaDataUserException, JDOMetaDataFatalError
    {
        final String className = pathToName(classPath);
        final PersistenceFieldElement pfe
            = model.getPersistenceField(className, fieldName);
        if (pfe == null
            || pfe.getPersistenceType() != PersistenceFieldElement.PERSISTENT)
            return -1;

        return pfe.getFieldNumber();
    }
View Full Code Here

        // exctract field names into result array
        final PersistenceFieldElement[] pfes = pce.getFields();
        final int nofFields = (pfes != null  ?  pfes.length  :  0);
        final String[] names = new String[nofFields];
        for (int i = 0; i < nofFields; i++) {
            final PersistenceFieldElement pfe = pfes[i];
            names[i] = pfe.getName();

            //@olsen: debugging check
            if (false) {
                if (pfe.getPersistenceType()
                    != PersistenceFieldElement.PERSISTENT) {
                    final String msg
                        = ("Getting persistent field names: " //NOI18N
                           + "Encountered non-persistent field '"//NOI18N
                           + names[i] + "' for class " + classPath);//NOI18N
View Full Code Here

                        // 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

            getPersistenceClass(pcClassName).getFields();
          int i, count = ((fields != null) ? fields.length : 0);

          for (i = 0; i < count; i++)
          {
            PersistenceFieldElement pfe = fields[i];

            if (pfe.isKey())
              return Arrays.asList(new String[]{pfe.getName()});
          }
          break;
      }
    }
View Full Code Here

    if (returnObject == null)
    {
      // can't call isPersistent or isKey because that calls
      // hasField which calls getField and that would end up
      // in an endless loop
      PersistenceFieldElement field =
        getPersistenceFieldInternal(className, fieldName);

      if (field != null)
      {
        String ejbName = getEjbName(className);
        String ejbFieldName = nameMapper.
          getEjbFieldForPersistenceField(className, fieldName);

        // Check if this is the auto-added field for unknown pk
        // support.  If so, return a private field of type Long.
        if (field.isKey() && (ejbName != null) &&
          (nameMapper.getKeyClassTypeForEjbName(ejbName) ==
          NameMapper.UNKNOWN_KEY_CLASS))
        {
          returnObject = new MemberWrapper(ejbFieldName,
            Long.class, Modifier.PRIVATE,
View Full Code Here

   * @return <code>true</code> if this field name represents a key field;
   * <code>false</code> otherwise.
   */
  public boolean isKey (String className, String fieldName)
  {
    PersistenceFieldElement field =
      getPersistenceField(className, fieldName);

    return field != null ? field.isKey() : false;
  }
View Full Code Here

TOP

Related Classes of com.sun.jdo.api.persistence.model.jdo.PersistenceFieldElement

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.