openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r810744 - 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/embed/TestEmbeddable.java
Date Thu, 03 Sep 2009 00:45:18 GMT
Author: fancy
Date: Thu Sep  3 00:45:17 2009
New Revision: 810744

URL: http://svn.apache.org/viewvc?rev=810744&view=rev
Log:
OPENJPA-1283 Incorrect SQL for a JPQL query selecting Map value from an elementCollection
of a Map and the map the value is an embeddable

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/embed/TestEmbeddable.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=810744&r1=810743&r2=810744&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
Thu Sep  3 00:45:17 2009
@@ -33,6 +33,7 @@
 import org.apache.openjpa.jdbc.meta.Strategy;
 import org.apache.openjpa.jdbc.meta.ValueMapping;
 import org.apache.openjpa.jdbc.meta.strats.HandlerCollectionTableFieldStrategy;
+import org.apache.openjpa.jdbc.meta.strats.HandlerHandlerMapTableFieldStrategy;
 import org.apache.openjpa.jdbc.meta.strats.LRSMapFieldStrategy;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.ForeignKey;
@@ -320,7 +321,10 @@
                         Strategy strategy = pstate.field.getStrategy();
                         if (strategy instanceof HandlerCollectionTableFieldStrategy) {
                             return ((HandlerCollectionTableFieldStrategy) strategy).
-                                getElementColumns(elem.getTypeMapping());               
            
+                                getElementColumns(elem.getTypeMapping());
+                        } else if (strategy instanceof HandlerHandlerMapTableFieldStrategy)
{
+                            return ((HandlerHandlerMapTableFieldStrategy) strategy).
+                            getValueColumns(elem.getTypeMapping());
                         }
                     }
                     if (pstate.joinedRel && elem.getTypeCode() == JavaTypes.PC)

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java?rev=810744&r1=810743&r2=810744&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
Thu Sep  3 00:45:17 2009
@@ -182,6 +182,7 @@
     public void testMapKeyTemporal() {
         createObjMapKeyTemporal();
         findObjMapKeyTemporal();
+        queryObjMapKeyTemporal();
     }
 
     public void testEntityA_Embed_MappedToOneCascadeDelete() {
@@ -2356,6 +2357,17 @@
         assertEquals(3, item.getImages().size());
     }
     
+    public void queryObjMapKeyTemporal() {
+        EntityManager em = emf.createEntityManager();
+        String jpql = "SELECT VALUE(img) FROM Item5 item, IN (item.images) img " + 
+            "WHERE img.fName = :fName and item.id = :id";
+        Query q = em.createQuery(jpql);
+        q.setParameter("fName", "file1");
+        q.setParameter("id", 1);
+        List coll = q.getResultList();
+        assertEquals(1, coll.size());
+    }
+
     public void queryItem(EntityManagerFactory emf) {
         EntityManager em = emf.createEntityManager();
         EntityTransaction tran = em.getTransaction();



Mime
View raw message