openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1530347 - in /openjpa/branches/2.2.1.x: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/external/ openjpa-persistence-jdbc/src/test/java/org/apache/op...
Date Tue, 08 Oct 2013 16:50:13 GMT
Author: hthomann
Date: Tue Oct  8 16:50:13 2013
New Revision: 1530347

URL: http://svn.apache.org/r1530347
Log:
OPENJPA-2425: SELECT fields with @ExternalValues defined returns datastore values instead
of unmapped fields - applied Albert Lee's patch to 2.2.1.x.

Modified:
    openjpa/branches/2.2.1.x/   (props changed)
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/external/TestExternalValues.java
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/onetomany/
  (props changed)

Propchange: openjpa/branches/2.2.1.x/
------------------------------------------------------------------------------
  Merged /openjpa/branches/2.1.x:r1530146

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java?rev=1530347&r1=1530346&r2=1530347&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
Tue Oct  8 16:50:13 2013
@@ -918,14 +918,18 @@ public class PCPath
         }
 
         Object ret;
-        if (_key)
+        if (_key) {
             // Map key is a java primitive type
-            //    example: Map<Integer, Employee> emps
-            ret = res.getObject(pstate.cols[0],
-                null, pstate.joins);
-        else
-            ret = pstate.field.loadProjection(ctx.store, ctx.fetch, res, 
-                pstate.joins);
+            // example: Map<Integer, Employee> emps
+            ret = res.getObject(pstate.cols[0], null, pstate.joins);
+        } else {
+            ret = pstate.field.loadProjection(ctx.store, ctx.fetch, res, pstate.joins);
+        }
+        
+        if (pstate.field.isExternalized()) {
+            ret = pstate.field.getFieldValue(ret, ctx.store.getContext());            
+        }
+        
         if (_cast != null)
             ret = Filters.convert(ret, _cast);
         return ret;

Modified: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/external/TestExternalValues.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/external/TestExternalValues.java?rev=1530347&r1=1530346&r2=1530347&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/external/TestExternalValues.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/external/TestExternalValues.java
Tue Oct  8 16:50:13 2013
@@ -18,6 +18,9 @@
  */
 package org.apache.openjpa.persistence.external;
 
+import java.util.Iterator;
+import java.util.List;
+
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 
@@ -55,6 +58,30 @@ public class TestExternalValues extends 
         Assert.assertEquals("MEDIUM", aPrime.getS2());
         Assert.assertEquals(true, aPrime.getUseStreaming());
 
+        em.getTransaction().begin();
+
+        entity = new EntityA();
+        entity.setS1("LARGE");
+        entity.setS2("LARGE");
+        entity.setUseStreaming(false);
+        em.persist(entity);
+
+        em.getTransaction().commit();
+
+        q = em.createQuery("SELECT t0.id, t0.s1, t0._useStreaming, t0.s2 FROM EntityA t0
ORDER BY t0.s1 DESC");
+        List<Object[]> res = q.getResultList();
+
+        Iterator<Object[]> itr = res.iterator();
+        Object[] values = itr.next();
+        Assert.assertEquals("SMALL", values[1]);
+        Assert.assertEquals(Boolean.TRUE, values[2]);
+        Assert.assertEquals("MEDIUM", values[3]);
+
+        values = itr.next();
+        Assert.assertEquals("LARGE", values[1]);
+        Assert.assertEquals(Boolean.FALSE, values[2]);
+        Assert.assertEquals("LARGE", values[3]);
+        
         em.close();
     }
 

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/onetomany/
------------------------------------------------------------------------------
  Merged /openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/onetomany:r1530146



Mime
View raw message