String batchOps = "BEGIN BATCH INSERT INTO CassandraBatchEntity (user_name, password, name) VALUES ('user2', 'ch@ngem3b', 'second user') UPDATE CassandraBatchEntity SET password = 'ps22dhds' WHERE user_name = 'user2' INSERT INTO CassandraBatchEntity (user_name, password) VALUES ('user3', 'ch@ngem3c') DELETE name FROM CassandraBatchEntity WHERE user_name = 'user2' INSERT INTO CassandraBatchEntity (user_name, password, name) VALUES ('user4', 'ch@ngem3c', 'Andrew') APPLY BATCH";
EntityManager em = emf.createEntityManager();
Map<String, Client> clientMap = (Map<String, Client>) em.getDelegate();
DSClient pc = (DSClient) clientMap.get(_PU);
pc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
Query q = em.createNativeQuery(useNativeSql);
// q.getResultList();
q.executeUpdate();
pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
q = em.createNativeQuery(createColumnFamily);
// q.getResultList();
q.executeUpdate();
pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
q = em.createNativeQuery(batchOps);
// q.getResultList();
q.executeUpdate();
q = em.createNativeQuery("select * from CassandraBatchEntity", CassandraBatchEntity.class);