Refine search
/** * @return cql query statement to delete a task_id to workflow_id mapping from the "task_lookup" table */ public String getDeleteTaskLookupStatement() { return QueryBuilder.delete() .from(keyspace, TABLE_TASK_LOOKUP) .where(eq(TASK_ID_KEY, bindMarker())) .getQueryString(); }
@Override public void deleteMessageData( final UUID messageId ) { logger.trace("deleteMessageData {}", messageId); Clause messageIdClause = QueryBuilder.eq(COLUMN_MESSAGE_ID, messageId); Statement delete = QueryBuilder.delete().from(TABLE_MESSAGE_DATA).where(messageIdClause); cassandraClient.getApplicationSession().execute(delete); }
@Override public void removeByExternalIdAndTenantId(String externalId, String tenantId) { LOG.debug("Try to remove endpoint user by external id {} and tenant id {}", externalId, tenantId); execute(delete().from(getColumnFamilyName()) .where(eq(EP_USER_EXTERNAL_ID_PROPERTY, externalId)) .and(eq(EP_USER_TENANT_ID_PROPERTY, tenantId))); }
private ImmutableList<BuiltStatement> nonIdempotentBuiltStatements() { return ImmutableList.of( update("foo").with(append("l", 1)).where(eq("k", 1)), // append to list update("foo").with(set("v", 1)).and(prepend("l", 1)).where(eq("k", 1)), // prepend to list update("foo").with(incr("c")).where(eq("k", 1)), // counter update update("foo").with(set("v", Lists.newArrayList(now()))).where(eq("k", 1)), update("foo").with(set("v", Lists.newArrayList(uuid()))).where(eq("k", 1)), delete().from("foo").where(lt("k", fcall("now"))), delete().from("foo").where(lt("k", now())), update("foo").where(eq("k", fcall("now"))), delete().listElt("a", 1).from("test_coll"), update("foo").with(set("v", 0)).onlyIf(contains("hello", "world")), insertInto("foo").value("k", 1).value("v", Sets.newHashSet(now())).ifNotExists(), delete().from("foo").where(eq("k", 2)).ifExists(), delete().from("foo").onlyIf(eq("k", 2)),
delete = delete("a", "b", "c").from("foo").using(timestamp(0)).where(eq("k", 1)); assertEquals(delete.toString(), query); delete = delete().listElt("a", 3).mapElt("b", "foo").column("c").from("foo").where(eq("k", 1)); assertEquals(delete.toString(), query); .column("c") .from("foo") .where(eq("k", 1)); assertEquals(delete.toString(), query); delete = delete().all().from("foo").using(timestamp(1240003134L)).where(eq("k", "value")); assertEquals(delete.toString(), query); delete = delete().from("foo").using(timestamp(1240003134L)).where(eq("k", "value")); assertEquals(delete.toString(), query); delete("a", "b", "c") .from("foo", "bar") .where() .and(eq("k", 1)) .using(timestamp(1240003134L)); assertEquals(delete.toString(), query); delete = delete().from("foo", "bar").where(eq("k1", "foo")).and(eq("k2", 1)); assertEquals(delete.toString(), query); delete().from("foo").using(timestamp(-1240003134L)); fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) {
delete = delete().from("foo WHERE k=4"); assertEquals(delete.toString(), query); delete = delete().from("foo").where(eq("k", "4 AND c=5")); assertEquals(delete.toString(), query); delete = delete().from("foo").where(eq("k", "4' AND c='5")); assertEquals(delete.toString(), query); delete = delete().from("foo").where(eq("k", "4' OR '1'='1")); assertEquals(delete.toString(), query); delete = delete().from("foo").where(eq("k", "4; --test comment;")); assertEquals(delete.toString(), query); delete = delete("a", "b").from("foo").where(in("a", "b", "c'); --comment")); assertEquals(delete.toString(), query); delete = delete().from("foo").where(gt("k=1 OR k", 42)); assertEquals(delete.toString(), query); delete = delete().from("foo").where(gt(token("k)>0 OR token(k"), fcall("token", 42))); assertEquals(delete.toString(), query);
private void initDeleteIfIdStatement() { Delete delete = generateDelete(table, pkColumns, false); Delete.Conditions deleteIf = delete.onlyIf(eq(exchangeIdColumn, bindMarker())); deleteIf = applyConsistencyLevel(deleteIf, writeConsistencyLevel); LOGGER.debug("Generated Delete If Id {}", deleteIf); deleteIfIdStatement = getSession().prepare(deleteIf); }
@Override public void removeNotificationsByAppId(String appId) { LOG.debug("Remove endpoint notifications by app id {}", appId); Statement deleteEpNfs = delete().from(getColumnFamilyName()) .where( QueryBuilder.in( ET_NF_ENDPOINT_KEY_HASH_PROPERTY, cassandraEpByAppIdDao.getEpIdsListByAppId(appId))); LOG.trace("Execute query {}", deleteEpNfs); execute(deleteEpNfs); }
private Delete buildDelete(Id label, String ownerVertex, Directions direction) { Delete delete = QueryBuilder.delete().from(edgesTable(direction)); delete.where(formatEQ(HugeKeys.OWNER_VERTEX, ownerVertex)); delete.where(formatEQ(HugeKeys.DIRECTION, direction.code())); delete.where(formatEQ(HugeKeys.LABEL, label.asLong())); return delete; }
/** * Adds a where clause to the DELETE statement these options are part of. * * @param clause clause to add. * @return the WHERE clause of the DELETE statement these options are part of. */ public Where where(Clause clause) { return statement.where(clause); } }
@Override void modifyQueryString(BuiltStatement query) { if (query instanceof Insert) { ((Insert) query).using().and(QueryBuilder.timestamp(QueryBuilder.bindMarker())); } else if (query instanceof Delete) { ((Delete) query).using().and(QueryBuilder.timestamp(QueryBuilder.bindMarker())); } else { throw new AssertionError("Unexpected query type: " + query.getClass()); } }
/** * Adds an option to the DELETE statement this WHERE clause is part of. * * @param using the using clause to add. * @return the options of the DELETE statement this WHERE clause is part of. */ public Options using(Using using) { return statement.using(using); }
/** * Adds a condition to the DELETE statement this WHERE clause is part of. * * @param condition the condition to add. * @return the conditions for the DELETE statement this WHERE clause is part of. */ public Conditions onlyIf(Clause condition) { return statement.onlyIf(condition); } }
/** * Sets the 'IF EXISTS' option for the DELETE statement this WHERE clause is part of. * * <p> * * <p>A delete with that option will report whether the statement actually resulted in data * being deleted. The existence check and deletion are done transactionally in the sense that if * multiple clients attempt to delete a given row with this option, then at most one may * succeed. * * <p>Please keep in mind that using this option has a non negligible performance impact and * should be avoided when possible. * * @return the DELETE statement this WHERE clause is part of. */ public Delete ifExists() { return statement.ifExists(); }
@Override public void remove(String applicationId, String credentialsId) { LOG.debug("Deleting credential by applicationID[{}] and credentialsID[{}]", applicationId, credentialsId); Delete.Where query = delete().from(getColumnFamilyName()) .where(eq(CREDENTIALS_ID_PROPERTY, credentialsId)) .and(eq(CREDENTIALS_APPLICATION_ID_PROPERTY, applicationId)); execute(query); } }
private ImmutableList<BuiltStatement> nonIdempotentBuiltStatements() { return ImmutableList.of( update("foo").with(append("l", 1)).where(eq("k", 1)), // append to list update("foo").with(set("v", 1)).and(prepend("l", 1)).where(eq("k", 1)), // prepend to list update("foo").with(incr("c")).where(eq("k", 1)), // counter update update("foo").with(set("v", Lists.newArrayList(now()))).where(eq("k", 1)), update("foo").with(set("v", Lists.newArrayList(uuid()))).where(eq("k", 1)), delete().from("foo").where(lt("k", fcall("now"))), delete().from("foo").where(lt("k", now())), update("foo").where(eq("k", fcall("now"))), delete().listElt("a", 1).from("test_coll"), update("foo").with(set("v", 0)).onlyIf(contains("hello", "world")), insertInto("foo").value("k", 1).value("v", Sets.newHashSet(now())).ifNotExists(), delete().from("foo").where(eq("k", 2)).ifExists(), delete().from("foo").onlyIf(eq("k", 2)),