openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r765064 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java
Date Wed, 15 Apr 2009 06:18:08 GMT
Author: fancy
Date: Wed Apr 15 06:18:07 2009
New Revision: 765064

URL: http://svn.apache.org/viewvc?rev=765064&view=rev
Log:
OPENJPA-1035 JPA2 Query allow map key/value path to appear as argument to scalar functions

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java?rev=765064&r1=765063&r2=765064&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
Wed Apr 15 06:18:07 2009
@@ -779,15 +779,10 @@
 
         Object ret;
         if (_key)
-            if (pstate.field.getKey().getValueMappedBy() != null)
-                ret = ((FieldMapping) pstate.field.getKey().
-                    getValueMappedByMetaData()).
-                    loadProjection(ctx.store, ctx.fetch, res, pstate.joins);
-            else
-                // Map key is a java primitive type
-                //    example: Map<Integer, Employee> emps
-                ret = res.getObject(pstate.cols[0],
-                    null, pstate.joins);
+            // 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);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java?rev=765064&r1=765063&r2=765064&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java
Wed Apr 15 06:18:07 2009
@@ -116,6 +116,46 @@
         if (!inMemory)
             assertTrue(sql.get(0).toUpperCase().indexOf(" GROUP BY ") != -1);
 
+        query = "select KEY(e) from Department d, " +
+            " in (d.emps) e where VALUE(e).department.deptId = 1" +
+            " ORDER BY KEY(e).fName";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Department.class);
+        rs = q.getResultList();
+        if (!inMemory)
+            assertEquals(((EmployeeName) rs.get(0)).getFName(), "f1");
+
+        query = "select KEY(e) from Department d, " +
+            " in (d.emps) e where VALUE(e).name.fName = 'f1'" +
+            " ORDER BY KEY(e).fName";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Department.class);
+        rs = q.getResultList();
+        if (!inMemory)
+            assertEquals(((EmployeeName) rs.get(0)).getFName(), "f1");
+
+        query = "select KEY(e) from Department d, " +
+            " in (d.emps) e where SUBSTRING(VALUE(e).name.fName, 1) = 'f1'" +
+            " ORDER BY KEY(e).fName";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Department.class);
+        rs = q.getResultList();
+        if (!inMemory)
+            assertEquals(((EmployeeName) rs.get(0)).getFName(), "f1");
+
+        query = "select KEY(e) from Department d, " +
+            " in (d.emps) e where LOCATE(VALUE(e).name.fName, 'f1') <> 0" +
+            " ORDER BY KEY(e).fName";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Department.class);
+        rs = q.getResultList();
+        if (!inMemory)
+            assertEquals(((EmployeeName) rs.get(0)).getFName(), "f1");
+
         em.close();
     }
 



Mime
View raw message