glassfish
  1. glassfish
  2. GLASSFISH-925

Inproper error message when mapped superclass is mis-used as a target

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.1pe
    • Fix Version/s: 9.1pe_dev
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Sun

    • Issuezilla Id:
      925

      Description

      I am trying to test @AssociationOverride
      in JSR220 Persistence 2.1.9.2 example.
      I found that I can't set relationship on
      a concrete class as mapped superclass.

      I used MappedSupperclasses , e.g.

      @MappedSuperclass
      public class Owner {

      private OwnerInfo accountOwnerInfo;
      @OneToOne
      public OwnerInfo getAccountOwnerInfo()

      { return accountOwnerInfo; }

      It has a OneToOne relationship an Entity

      @Entity
      public class OwnerInfo
      implements java.io.Serializable {
      private Owner accountOwner;
      @OneToOne(mappedBy="accountOwnerInfo")
      public Owner getAccountOwner()

      I got error "Missing meta data for class [Owner]".

      Local Exception Stack:

      [TopLink Config]: 2006.08.11 01:39:48.887--
      ServerSession(15041882)-- The target entity (reference)
      class for the one to one mapping element
      [public Owner OwnerInfo.getAccountOwner()] is being
      defaulted to: class Owner. Exception in thread "main"
      java.lang.reflect.InvocationTargetException
      ......
      Caused by: Exception [TOPLINK-7243] (Oracle TopLink
      Essentials - 2006.7 (Build 060731)):
      oracle.toplink.essentials.exceptions.ValidationException
      Exception Description: Missing meta data for class [Owner].
      Ensure the class is not being excluded from your
      persistence unit by a
      <exclude-unlisted-classes>true</exclude-unlisted-classes>
      setting. If this is the case, you will need to include
      the class directly by adding a <class>[Owner]</class>
      entry for your persistence-unit.
      at oracle.toplink.essentials.exceptions.ValidationException.
      classNotListedInPersistenceUnit(ValidationException.java:2116)
      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.
      MetadataProject.getDescriptor(MetadataProject.java:237)

      After I commented out mapping in OwnerInfo.java, e.g.
      // @OneToOne(mappedBy="accountOwnerInfo")
      the error went away.

      My test was done on AS9.1 Build 11.

        Issue Links

          Activity

          Hide
          kylechen added a comment -

          The bug has been fixed, as well as issue 940, please review attached code diff
          before/after

          Show
          kylechen added a comment - The bug has been fixed, as well as issue 940, please review attached code diff before/after
          Hide
          kylechen added a comment -

          Created an attachment (id=422)
          code change diff before and after

          Show
          kylechen added a comment - Created an attachment (id=422) code change diff before and after
          Hide
          tware added a comment -

          Please ignore the above comments about the fix and the merge_diffs file.

          Show
          tware added a comment - Please ignore the above comments about the fix and the merge_diffs file.
          Hide
          Sanjeeb Sahoo added a comment -

          Fix details: The core of the changes is overloading getReferenceDescriptor()
          method in RelationshipAccessor.java and doing necessary check there:
          /**

          • INTERNAL:
          • Return the reference metadata descriptor for this accessor.
          • This method does additional checks to make sure that the target
          • entity is indeed an entity class.
            */
            public MetadataDescriptor getReferenceDescriptor()
            Unknown macro: { MetadataDescriptor result; try { result = super.getReferenceDescriptor(); } catch (ValidationException ve) { result = null; } if(result == null || result.getDescriptor().isAggregateDescriptor()) { m_validator.throwNonEntityTargetInRelationship( m_descriptor.getJavaClass(), getReferenceClass(), m_accessibleObject.getAnnotatedElement()); } return result; }

          In addition to this we need to add the new ValidationException in the validation
          framework.

          Checking in src/java/oracle/toplink/essentials/exceptions/ValidationException.java;
          /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/exceptions/ValidationException.java,v
          <-- ValidationException.java
          new revision: 1.26; previous revision: 1.25
          done
          Checking in
          src/java/oracle/toplink/essentials/exceptions/i18n/ValidationExceptionResource.java;
          /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/exceptions/i18n/ValidationExceptionResource.java,v
          <-- ValidationExceptionResource.java
          new revision: 1.25; previous revision: 1.24
          done
          Checking in
          src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataValidator.java;
          /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataValidator.java,v
          <-- MetadataValidator.java
          new revision: 1.10; previous revision: 1.9
          done
          Checking in
          src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/RelationshipAccessor.java;
          /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/RelationshipAccessor.java,v
          <-- RelationshipAccessor.java
          new revision: 1.3; previous revision: 1.2
          done

          Show
          Sanjeeb Sahoo added a comment - Fix details: The core of the changes is overloading getReferenceDescriptor() method in RelationshipAccessor.java and doing necessary check there: /** INTERNAL: Return the reference metadata descriptor for this accessor. This method does additional checks to make sure that the target entity is indeed an entity class. */ public MetadataDescriptor getReferenceDescriptor() Unknown macro: { MetadataDescriptor result; try { result = super.getReferenceDescriptor(); } catch (ValidationException ve) { result = null; } if(result == null || result.getDescriptor().isAggregateDescriptor()) { m_validator.throwNonEntityTargetInRelationship( m_descriptor.getJavaClass(), getReferenceClass(), m_accessibleObject.getAnnotatedElement()); } return result; } In addition to this we need to add the new ValidationException in the validation framework. Checking in src/java/oracle/toplink/essentials/exceptions/ValidationException.java; /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/exceptions/ValidationException.java,v <-- ValidationException.java new revision: 1.26; previous revision: 1.25 done Checking in src/java/oracle/toplink/essentials/exceptions/i18n/ValidationExceptionResource.java; /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/exceptions/i18n/ValidationExceptionResource.java,v <-- ValidationExceptionResource.java new revision: 1.25; previous revision: 1.24 done Checking in src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataValidator.java; /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataValidator.java,v <-- MetadataValidator.java new revision: 1.10; previous revision: 1.9 done Checking in src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/RelationshipAccessor.java; /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/RelationshipAccessor.java,v <-- RelationshipAccessor.java new revision: 1.3; previous revision: 1.2 done
          Hide
          sherryshen added a comment -

          Verified the fix in AS9.1PE Build 17 promoted.

          When the mapped superclass, Owner, is used as a target of a
          relationship, the validation exception is shown for the reason.

          Issue 925, A bi-directional OneToOne mapping
          Caused by: Exception [TOPLINK-7250] (Oracle TopLink Essentials

          • 2006.8 (Build 060908)):
            oracle.toplink.essentials.exceptions.ValidationException
            Exception Description: [class OwnerInfo] uses a non-entity [class Owner]
            as target entity in the relationship attribute [public Owner
            OwnerInfo.getAccountOwner()]

          Issue 940, Two uni-directional OneToOne mappings
          Caused by: Exception [TOPLINK-7250] (Oracle TopLink Essentials

          • 2006.8 (Build 060908)):
            oracle.toplink.essentials.exceptions.ValidationException
            Exception Description: [class Account] uses a non-entity [class Owner] as
            target entity in the relationship attribute [public Owner Account.getOwner()]
          Show
          sherryshen added a comment - Verified the fix in AS9.1PE Build 17 promoted. When the mapped superclass, Owner, is used as a target of a relationship, the validation exception is shown for the reason. Issue 925, A bi-directional OneToOne mapping Caused by: Exception [TOPLINK-7250] (Oracle TopLink Essentials 2006.8 (Build 060908)): oracle.toplink.essentials.exceptions.ValidationException Exception Description: [class OwnerInfo] uses a non-entity [class Owner] as target entity in the relationship attribute [public Owner OwnerInfo.getAccountOwner()] Issue 940, Two uni-directional OneToOne mappings Caused by: Exception [TOPLINK-7250] (Oracle TopLink Essentials 2006.8 (Build 060908)): oracle.toplink.essentials.exceptions.ValidationException Exception Description: [class Account] uses a non-entity [class Owner] as target entity in the relationship attribute [public Owner Account.getOwner()]

            People

            • Assignee:
              Sanjeeb Sahoo
              Reporter:
              sherryshen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: