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

SELECT fields with @ExternalValues defined returns datastore values instead of unmapped fields

    Details

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

      Description

      If entity fields is annotated with,

      @ExternalValues(

      { "SMALL=SML", "MEDIUM=MID", "LARGE=LRG" }

      )
      private String s1;

      Object query returns umapped value in the object,
      Query q = em.createQuery("SELECT a from EntityA a");
      EntityA aPrime = (EntityA) q.getSingleResult();
      Assert.assertEquals("SMALL", aPrime.getS1());

      However, field query returns mapped value from the datastore:
      q = em.createQuery("SELECT t0.s1 FROM EntityA t0");
      List<Object[]> res = q.getResultList();
      Iterator<Object[]> itr = res.iterator();
      Object[] values = itr.next();
      Assert.assertEquals("SMALL", values[1]); <<< FAILED here, values[1]=="SML"

      This problem also causes a similarly structured CritieriaAPI query to return incorrect values.

      If the field type is boolean, even if the database has "true" value, both of the above scenario will return false, due to new Boolean("non-true") always return false.

        Attachments

          Activity

            People

            • Assignee:
              allee8285 Albert Lee
              Reporter:
              allee8285 Albert Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: