DocumentRepositoryImpl extends AbstractCRUDRepository<Document> implements DocumentRepository { @Override public boolean exists(Identifier identifier) { if (identifier == null || identifier.isEmpty()) { return false; } Table table = identifier.getTable(); PreparedStatement existStmt = PreparedStatementFactory.getPreparedStatement(String.format(EXISTENCE_CQL, table.toDbTable(), Columns.ID), getSession()); BoundStatement bs = new BoundStatement(existStmt); bindIdentifier(bs, identifier); return (getSession().execute(bs).one().getLong(0) > 0); } 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 testExists() { System.out.println("exists"); Document testDocument = Fixtures.createTestDocument(); f.insertDocument(testDocument); DocumentRepository instance = new DocumentRepositoryImpl(f.getSession()); Identifier identifier = testDocument.getId(); boolean result = instance.exists(identifier); assertEquals(true, result); f.deleteDocument(testDocument); result = instance.exists(identifier); assertEquals(false, result); }