Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-588

Test for checking the absolute index of field metadata fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.1.0
    • None
    • None

    Description

      We have a JDO metadata test which checks for the absolute index positions for the entity fields that are returned by the getIndex method of the FieldMetaData.

      In this test ,we have an entity class MetaTest1
      public class MetaTest1 {

      // these should not be persistent
      private static int staticField;
      private final String finalField = null;
      private transient char transientField;
      private MetaTest4 metaTest4Field;
      private MetaTest4[] metaTest4ArrayField;
      private Object objectField;
      private Long longWrapperField;
      private double doubleField;

      // persistent fields – see metadata
      private String stringField;
      private Integer intWrapperField;
      private int intField;
      private MetaTest2 metaTest2Field;
      private MetaTest2[] metaTest2ArrayField;
      private int[] intArrayField;

      public static class Inner

      { private long longField; }

      }

      In the test, we get the MetaDataRepository and from it the ClassMetaData,
      then the FieldMetaData and so on.

      The test fails at the line:

      assertEquals(6, _metaTest1.getField('stringField').getIndex());

      Failure is :
      [testlogic] junit.framework.AssertionFailedError: expected:<6> but was:<8>
      [testlogic] at kodo.meta.TestClassMetaData.testAbsoluteFieldNumbering(TestClassMetaData.java:217)
      [testlogic] at com.solarmetric.test.AbstractTestCase.run(AbstractTestCase.java:132)

      The persistence mapping is defined in the JDO file

      <jdo>
      <package name="kodo.meta">
      <!-- class MetaTest1 -->
      <class name="MetaTest1">
      <!-- field longWrapperField -->
      <field name="longWrapperField" persistence-modifier="none">
      <!-- comment1 on comment-test extension -->
      <!-- comment2 on comment-test extension -->
      <extension vendor-name="test" key="comment-test" value="test"/>
      </field>
      <field name="objectField" persistence-modifier="none"/>
      <field name="transientField" persistence-modifier="none"/>
      <field name="doubleField" persistence-modifier="transactional"/>
      <field name="intField" embedded="false" default-fetch-group="false" null-value="exception"/>
      <field name="intWrapperField" null-value="default"/>
      </class>
      </package>
      </jdo>

      There is no metadata mapping available for the MetaTest2 class. Initially the metadata is populated using reflection and assigns index positions to metaTest2Field and metaTest4ArrayField fields. During resolution the FieldMetaData[] _fields is reset and when ClassMetadata.getDeclaredIndex() is called later it is reinitialized but we dont set the index value on the FieldMetadata once assigned and this fails the test as it does not get the expected value for the index for the stringField.

      Attachments

        1. openjpa-1.1.0-SNAPSHOT-r422266-650703.patch
          0.8 kB
          Sandeep Shrivastava

        Activity

          People

            Unassigned Unassigned
            sandeeps@bea.com Sandeep Shrivastava
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified