mirror of https://github.com/apache/openjpa.git
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:
parent
e55f36f813
commit
affdc073d0
|
@ -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<Integer, Employee> emps
|
||||
ret = res.getObject(pstate.cols[0],
|
||||
null, pstate.joins);
|
||||
// Map key is a java primitive type
|
||||
// example: Map<Integer, Employee> emps
|
||||
ret = res.getObject(pstate.cols[0],
|
||||
null, pstate.joins);
|
||||
else
|
||||
ret = pstate.field.loadProjection(ctx.store, ctx.fetch, res,
|
||||
pstate.joins);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue