openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r681781 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persi...
Date Fri, 01 Aug 2008 19:03:36 GMT
Author: ppoddar
Date: Fri Aug  1 12:03:34 2008
New Revision: 681781

URL: http://svn.apache.org/viewvc?rev=681781&view=rev
Log:
OPENJPA-485: ORDER BY clause in JPQL generates syntactically wrong SQL for TABLE_PER_CLASS
inheritance hierarchy

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/jpql/clauses/TestEJBClauses.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.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=681781&r1=681780&r2=681781&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
Fri Aug  1 12:03:34 2008
@@ -488,8 +488,11 @@
                     }
 
                     for (; from != null && from != to;
-                        from = from.getJoinablePCSuperclassMapping())
+                        from = from.getJoinablePCSuperclassMapping()) {
+                    	pstate.field = from.getFieldMapping(pstate.field
+                    	    .getName());
                         pstate.joins = from.joinSuperclass(pstate.joins, false);
+                    }
                 }
                 // nothing more to do from here on as we encountered an xpath action
                 if (action.op == Action.GET_XPATH)

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java?rev=681781&r1=681780&r2=681781&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java
Fri Aug  1 12:03:34 2008
@@ -165,16 +165,13 @@
         String failure = "SELECT DISTINCT s " +
             "FROM Student s WHERE" +
             " s.department.name = 'CompSci1'";
-
-        try {
-            List ls = em.createQuery(failure).getResultList();
-            fail(
-                "cannot compose path expressions from a path expression that evaluates to
a collection.");
-        }
-        catch (Exception e) {
-            //
-        }
-
+        // Changes related to OPENJPA-485 allows this query to pass.
+        // The query is not kosher as it does navigate through a 
+        // collection-valued-path-expression (s.department.name) where
+        // department is a Collection. 
+        // But we allow this because of the convenience of the query expression 
+        List ls = em.createQuery(failure).getResultList();
+        assertFalse(ls.isEmpty());
         endEm(em);
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java?rev=681781&r1=681780&r2=681781&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java
Fri Aug  1 12:03:34 2008
@@ -330,26 +330,22 @@
         createMixed();
 
         OpenJPAEntityManager em = emf.createEntityManager();
-        try {
-            Query q = em.createQuery("select o from MixedInterface o " +
-                "where o.intField = 4");
-            Collection c = q.getResultList();
-            Set seen = new HashSet();
-            assertEquals(2, c.size());
-            MixedInterface pc;
-            for (Iterator it = c.iterator(); it.hasNext();) {
-                pc = (MixedInterface) it.next();
-                assertEquals(4, pc.getIntField());
-                seen.add(pc.getClass());
-            }
-            assertEquals(2, seen.size());
-
-            fail("OPENJPA-481");
-        } catch (PersistenceException e) {
-            // expected
-        } finally {
-            em.close();
+        Query q = em.createQuery("select o from MixedInterface o " +
+            "where o.intField = 4");
+        Collection c = q.getResultList();
+        Set seen = new HashSet();
+        assertEquals(2, c.size());
+        MixedInterface pc;
+        for (Iterator it = c.iterator(); it.hasNext();) {
+            pc = (MixedInterface) it.next();
+            assertEquals(4, pc.getIntField());
+            seen.add(pc.getClass());
         }
+        assertEquals(2, seen.size());
+        
+        // Changes of OPENJPA-485 had the positive (but unintended) consequence
+        // of making this case pass, which was failing before as reported in
+        // OPENJPA-481
     }
 
     public void testQueryForMixedInterfaceImpls() {



Mime
View raw message