OpenJPA
  1. OpenJPA
  2. OPENJPA-2305

Canonical MetaModel class generation should not use inhertence

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.2.1.1
    • Fix Version/s: 2.2.1.1, 2.3.0
    • Component/s: criteria
    • Labels:
      None

      Description

      The generated source code for canonical metamodel classes mirrored the same inheritance hierarchy of the domain classes. This strategy exposed an error that resulted in wrong target SQL query under the following domain model
      a) A @MappedSuperClass M defined a primary key field x
      b) The primary key field x is an @EmbeddedId E
      c) An @Entity class D derived from M and navigated to the fields of E via x

      The solution is to generate canonical class D_.java as a flattened structure instead of inheriting from M_.java (as is done currently).

        Issue Links

          Activity

          Hide
          ASF subversion and git services added a comment -

          Commit 1495580 from allee8285@apache.org
          [ https://svn.apache.org/r1495580 ]

          OPENJPA-2305 Revert AnnotationProcess6 @SupportSourceVersion removal. This will be resolved under JIRA 2300.

          Show
          ASF subversion and git services added a comment - Commit 1495580 from allee8285@apache.org [ https://svn.apache.org/r1495580 ] OPENJPA-2305 Revert AnnotationProcess6 @SupportSourceVersion removal. This will be resolved under JIRA 2300.
          Hide
          ASF subversion and git services added a comment -

          Commit 1495579 from allee8285@apache.org
          [ https://svn.apache.org/r1495579 ]

          OPENJPA-2305 Revert AnnotationProcess6 @SupportSourceVersion removal. This will be resolved under JIRA 2300.

          Show
          ASF subversion and git services added a comment - Commit 1495579 from allee8285@apache.org [ https://svn.apache.org/r1495579 ] OPENJPA-2305 Revert AnnotationProcess6 @SupportSourceVersion removal. This will be resolved under JIRA 2300.
          Hide
          ASF subversion and git services added a comment -

          Commit 1495578 from allee8285@apache.org
          [ https://svn.apache.org/r1495578 ]

          OPENJPA-2305 Revert AnnotationProcess6 @SupportSourceVersion removal. This will be resolved under JIRA 2300.

          Show
          ASF subversion and git services added a comment - Commit 1495578 from allee8285@apache.org [ https://svn.apache.org/r1495578 ] OPENJPA-2305 Revert AnnotationProcess6 @SupportSourceVersion removal. This will be resolved under JIRA 2300.
          Hide
          ASF subversion and git services added a comment -

          Commit 1476467 from hthomann
          [ https://svn.apache.org/r1476467 ]

          OPENJPA-2305: Canonical MetaModel class generation should not use inhertence - back-ported to 2.2.x Pinaki Poddar's commit to trunk.

          Show
          ASF subversion and git services added a comment - Commit 1476467 from hthomann [ https://svn.apache.org/r1476467 ] OPENJPA-2305 : Canonical MetaModel class generation should not use inhertence - back-ported to 2.2.x Pinaki Poddar's commit to trunk.
          Hide
          ASF subversion and git services added a comment -

          Commit 1469408 from hthomann
          [ https://svn.apache.org/r1469408 ]

          OPENJPA-2305: Canonical MetaModel class generation should not use inhertence - applied Pinaki's trunk changes to 2.2.1.x.

          Show
          ASF subversion and git services added a comment - Commit 1469408 from hthomann [ https://svn.apache.org/r1469408 ] OPENJPA-2305 : Canonical MetaModel class generation should not use inhertence - applied Pinaki's trunk changes to 2.2.1.x.
          Hide
          ASF subversion and git services added a comment -

          Commit 1469090 from hthomann
          [ https://svn.apache.org/r1469090 ]

          OPENJPA-2305: Canonical MetaModel class generation should not use inhertence - applied Pinaki's trunk changes to 2.1.x.

          Show
          ASF subversion and git services added a comment - Commit 1469090 from hthomann [ https://svn.apache.org/r1469090 ] OPENJPA-2305 : Canonical MetaModel class generation should not use inhertence - applied Pinaki's trunk changes to 2.1.x.
          Hide
          ASF subversion and git services added a comment -

          Commit 1456614 from Pinaki Poddar
          [ https://svn.apache.org/r1456614 ]

          OPENJPA-2305: Downcast the attribute, if necessary, while navigating a path

          Show
          ASF subversion and git services added a comment - Commit 1456614 from Pinaki Poddar [ https://svn.apache.org/r1456614 ] OPENJPA-2305 : Downcast the attribute, if necessary, while navigating a path
          Hide
          ASF subversion and git services added a comment -

          Commit 1456574 from Pinaki Poddar
          [ https://svn.apache.org/r1456574 ]

          OPENJPA-2305: Revert to previous style of generated metamodel as flattening inherited variables violate the spec

          Show
          ASF subversion and git services added a comment - Commit 1456574 from Pinaki Poddar [ https://svn.apache.org/r1456574 ] OPENJPA-2305 : Revert to previous style of generated metamodel as flattening inherited variables violate the spec
          Hide
          Pinaki Poddar added a comment -

          As per spec, the inheritance hierarchy of the generated metamodel class must mirror that of the domain classes. However we need exact class as the generic parameter of the declared meta-fields. So the solution is as follows

          @Entity public class Base

          { private int x;}

          @Entity public class Derived extends Base {}

          public class Base_

          {public static volatile SingularAttribute<Base,Integer> x;}

          public class derived_ extends Base_

          {public static volatile SingularAttribute<Derived,Integer> x;}

          // rewrite the base variable with owning class as generic parameter

          Show
          Pinaki Poddar added a comment - As per spec, the inheritance hierarchy of the generated metamodel class must mirror that of the domain classes. However we need exact class as the generic parameter of the declared meta-fields. So the solution is as follows @Entity public class Base { private int x;} @Entity public class Derived extends Base {} public class Base_ {public static volatile SingularAttribute<Base,Integer> x;} public class derived_ extends Base_ {public static volatile SingularAttribute<Derived,Integer> x;} // rewrite the base variable with owning class as generic parameter
          Hide
          ASF subversion and git services added a comment -

          Commit 1451369 from Pinaki Poddar
          [ https://svn.apache.org/r1451369 ]

          OPENJPA-2305: Restore the inheritance hierarchy of the generated canonical metamodel to that of the domain model due to spec compliance, but flatten the attributes so that an inherited attribute uses generic parameter of owning class type instead of the declared supertype

          Show
          ASF subversion and git services added a comment - Commit 1451369 from Pinaki Poddar [ https://svn.apache.org/r1451369 ] OPENJPA-2305 : Restore the inheritance hierarchy of the generated canonical metamodel to that of the domain model due to spec compliance, but flatten the attributes so that an inherited attribute uses generic parameter of owning class type instead of the declared supertype

            People

            • Assignee:
              Pinaki Poddar
              Reporter:
              Pinaki Poddar
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Development