DocumentRepositoryImpl extends AbstractCRUDRepository<Document> implements DocumentRepository { @Override public Document update(Document entity) { Document old = read(entity.getId()); entity.setCreatedAt(old.getCreatedAt()); Table table = entity.getTable(); PreparedStatement updateStmt = PreparedStatementFactory.getPreparedStatement(String.format(CREATE_CQL, table.toDbTable(), Columns.ID), getSession()); BoundStatement bs = new BoundStatement(updateStmt); bindCreate(bs, entity); BatchStatement batch = new BatchStatement(BatchStatement.Type.LOGGED); batch.add(bs); try { List<BoundStatement> indexStatements = IndexMaintainerHelper.generateDocumentUpdateIndexEntriesStatements(getSession(), entity, bucketLocator); for (BoundStatement boundIndexStatement : indexStatements) { batch.add(boundIndexStatement); } getSession().execute(batch); return entity; } catch (IndexParseException e) { throw new RuntimeException(e); } } DocumentRepositoryImpl(Session session); @Override Document create(Document entity); @Override Document read(Identifier identifier); @Override QueryResponseWrapper readAll(String database, String tableString, int limit, long offset); @Override Document update(Document entity); @Override void delete(Document entity); @Override void delete(Identifier id); @Override boolean exists(Identifier identifier);  }
@Test public void testDoUpdate() { System.out.println("doUpdate"); Document testDocument = Fixtures.createTestDocument(); f.insertDocument(testDocument); DocumentRepository instance = new DocumentRepositoryImpl(f.getSession()); String newObject = "{\"newjson\": \"object\"}"; testDocument.setObjectAsString(newObject); Document result = instance.update(testDocument); assertEquals(testDocument, result); f.deleteDocument(testDocument); }