IndexMaintainerHelper { public static String getCQLStatementForInsert(Index index) { String key = index.getDatabaseName() + ":" + index.getTableName() + ":" + index.getName(); Cache iTableCQLCache = CacheFactory.getCache("iTableInsertCQL"); Element e = iTableCQLCache.get(key); if (e == null || e.getObjectValue() == null) { e = new Element(key, generateCQLStatementForInsert(index)); iTableCQLCache.put(e); } else { logger.trace("Pulling iTableInsertCQL from Cache: " + e.getObjectValue().toString()); } return (String) e.getObjectValue(); } private  IndexMaintainerHelper(); static List<BoundStatement> generateDocumentCreateIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static BoundStatement generateDocumentCreateIndexEntryStatement(Session session, Index index, Document entity, BucketLocator bucketLocator); static List<BoundStatement> generateDocumentUpdateIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static List<BoundStatement> generateDocumentDeleteIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static List<Index> getIndexForDocument(Session session, Document entity); static boolean hasIndexedFieldChanged(BSONObject oldObject, Index index, Document entity); static BSONObject getOldObjectForUpdate(Session session, Document entity); static String getCQLStatementForInsert(Index index); static String generateCQLStatementForInsert(Index index); static String getCQLStatementForWhereClauses(String CQL, Index index); static String generateCQLStatementForWhereClauses(String CQL, Index index); static final String ITABLE_INSERT_CQL; static final String ITABLE_UPDATE_CQL; static final String ITABLE_DELETE_CQL; }
@Test public void testGenerateCQLStatementForInsert2() { System.out.println("generateCQLStatementForInsert"); String expResult = "INSERT INTO mydb_mytable_myindexwithonefield (bucket, id, object, created_at, updated_at, myindexedfield) VALUES (?, ?, ?, ?, ?, ?);"; String result = IndexMaintainerHelper.getCQLStatementForInsert(index1); assertEquals(expResult, result); expResult = "INSERT INTO mydb_mytable_myindexwithtwofields (bucket, id, object, created_at, updated_at, myindexedfield1, myindexedfield2) VALUES (?, ?, ?, ?, ?, ?, ?);"; result = IndexMaintainerHelper.getCQLStatementForInsert(index2); assertEquals(expResult, result); }