/** * @test_category queries:builder * @jira_ticket JAVA-1286 * @jira_ticket CASSANDRA-7423 */ @Test(groups = "unit") public void should_handle_setting_udt_fields() throws Exception { assertThat( update("tbl") .with(set(path("a", quote("B")), "foo")) .and(set(raw("c.\"D\""), "bar")) .where(eq("k", 0)) .getQueryString()) .isEqualTo("UPDATE tbl SET a.\"B\"=?,c.\"D\"=? WHERE k=0;"); }
@Override public void updateAuthCodeValidStatus(String authCode, boolean valid) { Update.Where stmt = QueryBuilder.update(KEYSPACE_NAME, AUTH_CODE_TABLE_NAME) .with(QueryBuilder.set("valid", valid)) .where(QueryBuilder.eq("code", authCode)) ; try { session.execute(stmt); } catch (NoHostAvailableException e) { log.error("No host in the %s cluster can be contacted to execute the query.\n", session.getCluster()); } catch (QueryExecutionException e) { log.error("An exception was thrown by Cassandra because it cannot " + "successfully execute the query with the specified consistency level."); } catch (QueryValidationException e) { log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n", stmt.getQueryString())); } catch (IllegalStateException e) { log.error("The BoundStatement is not ready."); } }
@Override public void updateAccessTokenValidStatus(String accessToken, boolean valid) { Update.Where stmt = QueryBuilder.update(KEYSPACE_NAME, ACCESS_TOKEN_TABLE_NAME) .with(QueryBuilder.set("valid", valid)) .where(QueryBuilder.eq("access_token", accessToken)) ; try { session.execute(stmt); } catch (NoHostAvailableException e) { log.error("No host in the %s cluster can be contacted to execute the query.\n", session.getCluster()); } catch (QueryExecutionException e) { log.error("An exception was thrown by Cassandra because it cannot " + "successfully execute the query with the specified consistency level."); } catch (QueryValidationException e) { log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n", stmt.getQueryString())); } catch (IllegalStateException e) { log.error("The BoundStatement is not ready."); } }
} catch (QueryValidationException e) { log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n", stmt.getQueryString())); } catch (IllegalStateException e) { log.error("The BoundStatement is not ready.");
/** * @test_category queries:builder * @jira_ticket JAVA-1286 * @jira_ticket CASSANDRA-7423 */ @Test(groups = "unit") public void should_handle_setting_udt_fields() throws Exception { assertThat( update("tbl") .with(set(path("a", quote("B")), "foo")) .and(set(raw("c.\"D\""), "bar")) .where(eq("k", 0)) .getQueryString()) .isEqualTo("UPDATE tbl SET a.\"B\"=?,c.\"D\"=? WHERE k=0;"); }
/** * @return cql query statement to add a new task_id to workflow_id mapping to the "task_lookup" table */ public String getUpdateTaskLookupStatement() { return QueryBuilder.update(keyspace, TABLE_TASK_LOOKUP) .with(set(WORKFLOW_ID_KEY, bindMarker())) .where(eq(TASK_ID_KEY, bindMarker())) .getQueryString(); }
/** * @return cql query statement to update the total_partitions for a workflow in the "workflows" table */ public String getUpdateTotalPartitionsStatement() { return QueryBuilder.update(keyspace, TABLE_WORKFLOWS) .with(set(TOTAL_PARTITIONS_KEY, bindMarker())) .and(set(TOTAL_TASKS_KEY, bindMarker())) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, 1)) .getQueryString(); }
/** * @return cql query statement to update the total_tasks in a shard for a workflow in the "workflows" table */ public String getUpdateTotalTasksStatement() { return QueryBuilder.update(keyspace, TABLE_WORKFLOWS) .with(set(TOTAL_TASKS_KEY, bindMarker())) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, bindMarker())) .getQueryString(); }
/** * @return cql query statement to update a workflow in the "workflows" table */ public String getUpdateWorkflowStatement() { return QueryBuilder.update(keyspace, TABLE_WORKFLOWS) .with(set(PAYLOAD_KEY, bindMarker())) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, 1)) .and(eq(ENTITY_KEY, ENTITY_TYPE_WORKFLOW)) .and(eq(TASK_ID_KEY, "")) .getQueryString(); }