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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: