OpenJPA
  1. OpenJPA
  2. OPENJPA-2425

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

    Details

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

        Activity

        Albert Lee created issue -
        Albert Lee made changes -
        Field Original Value New Value
        Attachment OPENJPA-2425.patch [ 12601212 ]
        Albert Lee made changes -
        Patch Info Patch Available [ 10042 ]
        Heath Thomann made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.1.2 [ 12317142 ]
        Fix Version/s 2.3.0 [ 12319463 ]
        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 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development