private void testINClause()
{
if (USE_CQL)
{
Map<String, Client> clientMap = (Map<String, Client>) entityManager.getDelegate();
ThriftClient tc = (ThriftClient) clientMap.get(SEC_IDX_CASSANDRA_TEST);
tc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
Query findQuery;
List<PersonCassandra> allPersons;
findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN :idList");
List<String> idList = new ArrayList<String>();
idList.add("1");
idList.add("2");
idList.add("3");
findQuery.setParameter("idList", idList);
allPersons = findQuery.getResultList();
Assert.assertNotNull(allPersons);
Assert.assertEquals(3, allPersons.size());
findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN ?1");
findQuery.setParameter(1, idList);
allPersons = findQuery.getResultList();
Assert.assertNotNull(allPersons);
Assert.assertEquals(3, allPersons.size());
entityManager.close();
entityManager = emf.createEntityManager();
findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN :idList");
findQuery.setParameter("idList", new ArrayList<String>());
allPersons = findQuery.getResultList();
Assert.assertNotNull(allPersons);
Assert.assertTrue(allPersons.isEmpty());
findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN ('1', '2')");
allPersons = findQuery.getResultList();
Assert.assertNotNull(allPersons);
Assert.assertEquals(2, allPersons.size());
entityManager.close();
try
{
entityManager = emf.createEntityManager();
findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.age IN (10 , 20)");
allPersons = findQuery.getResultList();
Assert.fail();
}
catch (Exception e)
{
Assert.assertEquals(
"javax.persistence.PersistenceException: com.impetus.kundera.KunderaException: InvalidRequestException(why:IN predicates on non-primary-key columns (AGE) is not yet supported)",
e.getMessage());
}
tc.setCqlVersion(CassandraConstants.CQL_VERSION_2_0);
}
else
{
Query findQuery;
List<PersonCassandra> allPersons;