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 fcaf5d6cb..1aac32a41 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 @@ -779,15 +779,10 @@ public class PCPath 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 emps - ret = res.getObject(pstate.cols[0], - null, pstate.joins); + // Map key is a java primitive type + // example: Map emps + ret = res.getObject(pstate.cols[0], + null, pstate.joins); else ret = pstate.field.loadProjection(ctx.store, ctx.fetch, res, pstate.joins); diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java index 4bb2e213a..095af8379 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_26_ex3/TestSpec10_1_26_Ex3.java @@ -116,6 +116,46 @@ public class TestSpec10_1_26_Ex3 extends SQLListenerTestCase { 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(); }