List<String> userIdList = new ArrayList<String>();
userIdList.add("kk");
userIdList.add("dk");
userIdList.add("sk");
KunderaQuery kunderaQuery = getQueryObject(queryString, emf);
kunderaQuery.setParameter("userIdList", userIdList);
cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, Integer.MAX_VALUE);
Assert.assertNotNull(cqlQuery);
Assert.assertEquals(
"SELECT * FROM \"CompositeUser\" WHERE \"userId\" IN ('kk', 'dk', 'sk' ) ORDER BY \"tweetId\" ASC ALLOW FILTERING",
cqlQuery);
// In Query set Paramater with and clause.
queryString = "Select u from CassandraPrimeUser u WHERE u.key.userId IN :userIdList and p.name = 'kuldeep' ORDER BY u.key.tweetId ASC";
kunderaQuery = getQueryObject(queryString, emf);
kunderaQuery.setParameter("userIdList", userIdList);
cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);
Assert.assertNotNull(cqlQuery);
Assert.assertEquals(
"SELECT * FROM \"CompositeUser\" WHERE \"userId\" IN ('kk', 'dk', 'sk' ) AND \"name\" = 'kuldeep' ORDER BY \"tweetId\" ASC LIMIT 100 ALLOW FILTERING",
cqlQuery);
// In Query set Paramater with gt clause.
queryString = "Select u from CassandraPrimeUser u WHERE u.key IN :keyList";
List<CassandraCompoundKey> personIdList = new ArrayList<CassandraCompoundKey>();
UUID timeLineId1 = UUID.randomUUID();
personIdList.add(new CassandraCompoundKey("kk", 1, timeLineId1));
personIdList.add(new CassandraCompoundKey("vm", 2, timeLineId1));
personIdList.add(new CassandraCompoundKey("vs", 3, timeLineId1));
kunderaQuery = getQueryObject(queryString, emf);
kunderaQuery.setParameter("keyList", personIdList);
cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);
Assert.assertNotNull(cqlQuery);
Assert.assertTrue(cqlQuery.contains("SELECT * FROM \"CompositeUser\" WHERE "));
Assert.assertTrue(cqlQuery.contains("\"timeLineId\" IN (" + timeLineId1 + ", " + timeLineId1 + ", "
+ timeLineId1 + " )"));
Assert.assertTrue(cqlQuery.contains("\"userId\" IN ('kk', 'vm', 'vs' )"));
Assert.assertTrue(cqlQuery.contains("\"tweetId\" IN (1, 2, 3 )"));
Assert.assertTrue(cqlQuery.contains(" LIMIT 100"));
Assert.assertTrue(cqlQuery.contains(" AND "));
Assert.assertTrue(cqlQuery.indexOf(" AND ") > 0);
// In Query over non pk field set Paramater with gt clause.
queryString = "Select u from CassandraPrimeUser u WHERE u.key IN :keyList and u.name = 'vivek'";
kunderaQuery = getQueryObject(queryString, emf);
kunderaQuery.setParameter("keyList", personIdList);
cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);
Assert.assertNotNull(cqlQuery);
Assert.assertTrue(cqlQuery.contains("SELECT * FROM \"CompositeUser\" WHERE "));