diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java index 0cff107e4..c8e8f7ee2 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java @@ -488,8 +488,11 @@ public class PCPath } 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) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java index 86f0c4274..72685e2f8 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java @@ -165,16 +165,13 @@ public class TestEJBClauses extends AbstractTestCase { 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); } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java index ff7498a48..5c0db50c9 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestManagedInterfaces.java @@ -330,26 +330,22 @@ public class TestManagedInterfaces extends SingleEMFTestCase { 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() {