entityManager.persist(p1);
entityManager.persist(p2);
entityManager.persist(p3);
PersonCassandra personWithKey = new PersonCassandra();
personWithKey.setPersonId("111");
entityManager.persist(personWithKey);
col.put("1", p1);
col.put("2", p2);
col.put("3", p3);
entityManager.clear();
PersonCassandra p = findById(PersonCassandra.class, "1", entityManager);
Assert.assertNotNull(p);
Assert.assertEquals("vivek", p.getPersonName());
Assert.assertEquals(Day.thursday, p.getDay());
entityManager.clear();
Query q;
List<PersonCassandra> persons = queryOverRowkey();
assertFindByName(entityManager, PersonCassandra.class, PersonCassandra.class, "vivek", "personName");
assertFindByNameAndAge(entityManager, PersonCassandra.class, PersonCassandra.class, "vivek", "10", "personName");
assertFindByNameAndAgeGTAndLT(entityManager, PersonCassandra.class, PersonCassandra.class, "vivek", "10", "20",
"personName");
assertFindByNameAndAgeBetween(entityManager, PersonCassandra.class, PersonCassandra.class, "vivek", "10", "15",
"personName");
assertFindByRange(entityManager, PersonCassandra.class, PersonCassandra.class, "1", "2", "personId", true);
assertFindWithoutWhereClause(entityManager, PersonCassandra.class, PersonCassandra.class, true);
// perform merge after query.
for (PersonCassandra person : persons)
{
person.setPersonName("'after merge'");
entityManager.merge(person);
}
entityManager.clear();
p = findById(PersonCassandra.class, "1", entityManager);
Assert.assertNotNull(p);
Assert.assertEquals("'after merge'", p.getPersonName());
String updateQuery = "update PersonCassandra p set p.personName=''KK MISHRA'' where p.personId=1";
q = entityManager.createQuery(updateQuery);
q.executeUpdate();
entityManager.clear();
p = findById(PersonCassandra.class, "1", entityManager);
Assert.assertNotNull(p);
Assert.assertEquals("'KK MISHRA'", p.getPersonName());
// Delete without WHERE clause.
String deleteQuery = "DELETE from PersonCassandra";