OpenJPA
  1. OpenJPA
  2. OPENJPA-2343

Version field returns null when explicity projected from a JOIN in SELECT clause

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1, 2.3.0
    • Fix Version/s: 2.1.2, 2.2.1.1, 2.2.3, 2.3.0
    • Component/s: query
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      With these entities:

      @Entity
      public class Foo {
      private int id;
      private int version;
      @Id
      public int getId()

      { return id; }
      public void setId(int id) { this.id = id; }

      public void setVersion(int version) { this.version = version; }
      @Version
      public int getVersion() { return this.version; }
      }

      @Entity
      public class Bar{
      private int id;
      private Foo foo;
      @Id
      public int getId() { return id; }

      public void setId(int id)

      { this.id = id; }

      public void setFoo(Foo foo)

      { this.foo = foo; }

      @ManyToOne
      public Foo getFoo()

      { return foo; }

      }
      Insert a record for each associating foo with bar.

      Foo foo = new Foo();
      em.getTransaction().begin();
      em.persist(foo);
      Bar bar = new Bar();
      bar.setFoo(foo);
      em.persist(bar);
      em.getTransaction().commit();
      em.close();

      queries

      select bar.id as id, foo as foo from Bar bar join bar.foo foo
      The version field is available via foo.getVersion()

      select bar.id as id, foo.version as version from Bar bar join bar.foo foo
      version is always null.

      By enabling the jdbc debug I can see that the actual SQL being run is correct but the value is just not hydrated.

        Issue Links

          Activity

          howard kelsey created issue -
          howard kelsey made changes -
          Field Original Value New Value
          Description With these entities:

          @Entity
          public class Foo {
              private int id;
              private int version;
              @Id
          public int getId() {
          return id;
          }
          public void setId(int id) {
          this.id = id;
          }

          public void setVersion(int version) {
          this.version = version;
          }
          @Version
          public int getVersion() {
          return this.version;
          }
          }

          @Entity
          public class Bar{
          private int id;
          private Foo foo;
              @Id
          public int getId() {
          return id;
          }
          public void setId(int id) {
          this.id = id;
          }
              public void setFoo(Foo foo) {
                  this.foo = foo;
              }
              @ManyToOne
              public Foo getFoo() {
                  return foo;
              }
          }
          Insert a record for each associating foo with bar.

          Foo foo = new Foo();
          em.getTransaction().begin();
          em.persist(foo);
          Bar bar = new Bar();
          bar.setFoo(foo);
          em.persist(bar);
          em.getTransaction().commit();
          em.close();

          queries

          select bar.id as id, foo as foo from Bar bar join bar.foo foo
          The version field is available via foo.getVersion()

          select bar.id as id, foo.version as version from Bar bar join bar.foo foo
          version is always null.
          With these entities:

          @Entity
          public class Foo {
              private int id;
              private int version;
              @Id
          public int getId() {
          return id;
          }
          public void setId(int id) {
          this.id = id;
          }

          public void setVersion(int version) {
          this.version = version;
          }
          @Version
          public int getVersion() {
          return this.version;
          }
          }

          @Entity
          public class Bar{
          private int id;
          private Foo foo;
              @Id
          public int getId() {
          return id;
          }
          public void setId(int id) {
          this.id = id;
          }
              public void setFoo(Foo foo) {
                  this.foo = foo;
              }
              @ManyToOne
              public Foo getFoo() {
                  return foo;
              }
          }
          Insert a record for each associating foo with bar.

          Foo foo = new Foo();
          em.getTransaction().begin();
          em.persist(foo);
          Bar bar = new Bar();
          bar.setFoo(foo);
          em.persist(bar);
          em.getTransaction().commit();
          em.close();

          queries

          select bar.id as id, foo as foo from Bar bar join bar.foo foo
          The version field is available via foo.getVersion()

          select bar.id as id, foo.version as version from Bar bar join bar.foo foo
          version is always null.

          By enabling the jdbc debug I can see that the actual SQL being run is correct but the value is just not hydrated.
          howard kelsey made changes -
          Patch Info Patch Available [ 10042 ]
          howard kelsey made changes -
          Attachment OPENJPA-2343-2.2.1.x.patch [ 12572074 ]
          howard kelsey made changes -
          Attachment OPENJPA-2343-2.2.1.x.patch [ 12572074 ]
          howard kelsey made changes -
          Attachment OPENJPA-2343-2.2.1.x.patch [ 12572075 ]
          Rick Curtis made changes -
          Link This issue relates to OPENJPA-662 [ OPENJPA-662 ]
          Rick Curtis made changes -
          Assignee Rick Curtis [ curtisr7 ]
          Rick Curtis made changes -
          Summary Version field of related entity returns null when explicitly projected in SELECT clause Version field returns null when explicity projected from a JOIN in SELECT clause
          Rick Curtis made changes -
          Fix Version/s 2.3.0 [ 12319463 ]
          Affects Version/s 2.3.0 [ 12319463 ]
          Hide
          ASF subversion and git services added a comment -

          Commit 1533218 from Heath Thomann in branch 'openjpa/branches/2.1.x'
          [ https://svn.apache.org/r1533218 ]

          OPENJPA-2343: Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey.

          Show
          ASF subversion and git services added a comment - Commit 1533218 from Heath Thomann in branch 'openjpa/branches/2.1.x' [ https://svn.apache.org/r1533218 ] OPENJPA-2343 : Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey.
          Hide
          ASF subversion and git services added a comment -

          Commit 1533222 from Heath Thomann in branch 'openjpa/branches/2.2.1.x'
          [ https://svn.apache.org/r1533222 ]

          OPENJPA-2343: Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.1.x commit to 2.2.1.x.

          Show
          ASF subversion and git services added a comment - Commit 1533222 from Heath Thomann in branch 'openjpa/branches/2.2.1.x' [ https://svn.apache.org/r1533222 ] OPENJPA-2343 : Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.1.x commit to 2.2.1.x.
          Hide
          ASF subversion and git services added a comment -

          Commit 1533223 from Heath Thomann in branch 'openjpa/branches/2.2.x'
          [ https://svn.apache.org/r1533223 ]

          OPENJPA-2343: Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.2.1.x commit to 2.2.x.

          Show
          ASF subversion and git services added a comment - Commit 1533223 from Heath Thomann in branch 'openjpa/branches/2.2.x' [ https://svn.apache.org/r1533223 ] OPENJPA-2343 : Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.2.1.x commit to 2.2.x.
          Hide
          ASF subversion and git services added a comment -

          Commit 1533227 from Heath Thomann in branch 'openjpa/trunk'
          [ https://svn.apache.org/r1533227 ]

          OPENJPA-2343: Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.2.x commit to trunk.

          Show
          ASF subversion and git services added a comment - Commit 1533227 from Heath Thomann in branch 'openjpa/trunk' [ https://svn.apache.org/r1533227 ] OPENJPA-2343 : Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.2.x commit to trunk.
          Hide
          ASF subversion and git services added a comment -

          Commit 1533235 from Heath Thomann in branch 'openjpa/branches/2.3.x'
          [ https://svn.apache.org/r1533235 ]

          OPENJPA-2343: Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.2.x commit to 2.3.x.

          Show
          ASF subversion and git services added a comment - Commit 1533235 from Heath Thomann in branch 'openjpa/branches/2.3.x' [ https://svn.apache.org/r1533235 ] OPENJPA-2343 : Version field returns null when explicity projected from a JOIN in SELECT clause - based fix off of patch provided by Howard Kelsey. Merged 2.2.x commit to 2.3.x.
          Heath Thomann made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.1.2 [ 12317142 ]
          Fix Version/s 2.2.1.1 [ 12323484 ]
          Fix Version/s 2.2.3 [ 12324305 ]
          Resolution Fixed [ 1 ]
          Mark Struberg made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          230d 7h 34m 1 Heath Thomann 17/Oct/13 22:30
          Resolved Resolved Closed Closed
          596d 22h 48m 1 Mark Struberg 06/Jun/15 21:19

            People

            • Assignee:
              Rick Curtis
              Reporter:
              howard kelsey
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development