mirror of https://github.com/apache/openjpa.git
OPENJPA-1923: Remove restriction to enclose collection-valued query parameter in parentheses.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1060113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28a0c0da86
commit
01c9608fe6
|
@ -241,38 +241,6 @@ public class TestPreparedQueryCache extends AbstractPersistenceTestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCollectionValuedParams() {
|
|
||||||
OpenJPAEntityManager em = emf.createEntityManager();
|
|
||||||
String jpql = "select c.name from Department c where c.name in (:names) order by c.name";
|
|
||||||
List<String> params = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < DEPARTMENT_NAMES.length; i++)
|
|
||||||
params.add(DEPARTMENT_NAMES[i]);
|
|
||||||
|
|
||||||
List<String> rs = null;
|
|
||||||
List<String> rs2 = null;
|
|
||||||
try {
|
|
||||||
rs = (List<String>) em.createQuery(jpql).setParameter("names", params).getResultList();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// as expected - syntax for collection valued parameter should be :names;
|
|
||||||
}
|
|
||||||
assertNull(rs);
|
|
||||||
|
|
||||||
try {
|
|
||||||
rs2 = (List<String>) em.createQuery(jpql).setParameter("names", params).getResultList();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// as expected - syntax for collection valued parameter should be :names;
|
|
||||||
}
|
|
||||||
assertNull(rs2);
|
|
||||||
|
|
||||||
String jpql2 = "select c.name from Company c where c.name in :names order by c.name";
|
|
||||||
List<String> params2 = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < COMPANY_NAMES.length; i++)
|
|
||||||
params2.add(COMPANY_NAMES[i]);
|
|
||||||
rs = (List<String>) em.createQuery(jpql2).setParameter("names", params2).getResultList();
|
|
||||||
rs2 = (List<String>) em.createQuery(jpql2).setParameter("names", params2).getResultList();
|
|
||||||
assertEquals(rs.size(), rs2.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCollectionValuedParameterOfEntities() {
|
public void testCollectionValuedParameterOfEntities() {
|
||||||
OpenJPAEntityManager em = emf.createEntityManager();
|
OpenJPAEntityManager em = emf.createEntityManager();
|
||||||
String jpql1 = "select d from Department d where d.name in ('Marketing', 'Sales') order by d.name";
|
String jpql1 = "select d from Department d where d.name in ('Marketing', 'Sales') order by d.name";
|
||||||
|
|
Loading…
Reference in New Issue