OPENJPA-1035 JPA2 Query allow map key/value path to appear as argument to scalar functions

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@765064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Catalina Wei 2009-04-15 06:18:17 +00:00
parent e55f36f813
commit affdc073d0
2 changed files with 44 additions and 9 deletions

View File

@ -779,11 +779,6 @@ public class PCPath
Object ret; Object ret;
if (_key) 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 // Map key is a java primitive type
// example: Map<Integer, Employee> emps // example: Map<Integer, Employee> emps
ret = res.getObject(pstate.cols[0], ret = res.getObject(pstate.cols[0],

View File

@ -116,6 +116,46 @@ public class TestSpec10_1_26_Ex3 extends SQLListenerTestCase {
if (!inMemory) if (!inMemory)
assertTrue(sql.get(0).toUpperCase().indexOf(" GROUP BY ") != -1); 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(); em.close();
} }