@Test(groups = "short") @CassandraVersion( value = "2.0.7", description = "DELETE..IF EXISTS only supported in 2.0.7+ (CASSANDRA-5708)") public void conditionalDeletesTest() throws Exception { session() .execute(String.format("INSERT INTO %s.test_int (k, a, b) VALUES (1, 1, 1)", keyspace)); Statement delete; Row row; delete = delete().from(keyspace, TABLE_INT).where(eq("k", 2)).ifExists(); row = session().execute(delete).one(); assertFalse(row.getBool("[applied]")); delete = delete().from(keyspace, TABLE_INT).where(eq("k", 1)).ifExists(); row = session().execute(delete).one(); assertTrue(row.getBool("[applied]")); session() .execute(String.format("INSERT INTO %s.test_int (k, a, b) VALUES (1, 1, 1)", keyspace)); delete = delete().from(keyspace, TABLE_INT).where(eq("k", 1)).onlyIf(eq("a", 1)).and(eq("b", 2)); row = session().execute(delete).one(); assertFalse(row.getBool("[applied]")); delete = delete().from(keyspace, TABLE_INT).where(eq("k", 1)).onlyIf(eq("a", 1)).and(eq("b", 1)); row = session().execute(delete).one(); assertTrue(row.getBool("[applied]")); }
delete = delete().from("foo", "bar").where(eq("k1", "foo")).onlyIf(eq("a", 1)).and(eq("b", 2)); assertEquals(delete.toString(), query);
/** * Generate an ... <strong>IF layer2 = ?</strong> */ @SuppressWarnings("static-access") public final EntityLayer1_Delete.E Eq(final Layer2 layer2) { boundValues.add(layer2); encodedValues.add(meta.layer2.encodeFromJava(layer2, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.eq("layer2", QueryBuilder.bindMarker("layer2"))); return EntityLayer1_Delete.E.this; }
/** * Generate an ... <strong>IF anotherValue != ?</strong> */ @SuppressWarnings("static-access") public final EntityAsChild_Delete.E NotEq(final String anotherValue) { boundValues.add(anotherValue); encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue, Optional.of(cassandraOptions))); where.onlyIf(NotEq.of("child_value", QueryBuilder.bindMarker("child_value"))); return EntityAsChild_Delete.E.this; } }
/** * Generate an ... <strong>IF value < ?</strong> */ @SuppressWarnings("static-access") public final EntityAsChild_Delete.E Lt(final String value) { boundValues.add(value); encodedValues.add(meta.value.encodeFromJava(value, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lt("value", QueryBuilder.bindMarker("value"))); return EntityAsChild_Delete.E.this; }
/** * Generate an ... <strong>IF jdkZonedDateTime >= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexTypes_Delete.E Gte(final ZonedDateTime jdkZonedDateTime) { boundValues.add(jdkZonedDateTime); encodedValues.add(meta.jdkZonedDateTime.encodeFromJava(jdkZonedDateTime, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gte("jdkzoneddatetime", QueryBuilder.bindMarker("jdkzoneddatetime"))); return EntityWithComplexTypes_Delete.E.this; }
/** * Generate an ... <strong>IF timeuuid >= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexTypes_Delete.E Gte(final UUID timeuuid) { boundValues.add(timeuuid); encodedValues.add(meta.timeuuid.encodeFromJava(timeuuid, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gte("timeuuid", QueryBuilder.bindMarker("timeuuid"))); return EntityWithComplexTypes_Delete.E.this; }
/** * Generate an ... <strong>IF objectByte > ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexTypes_Delete.E Gt(final Byte objectByte) { boundValues.add(objectByte); encodedValues.add(meta.objectByte.encodeFromJava(objectByte, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gt("object_byte", QueryBuilder.bindMarker("object_byte"))); return EntityWithComplexTypes_Delete.E.this; }
/** * Generate an ... <strong>IF value < ?</strong> */ @SuppressWarnings("static-access") public final EntityWithClusteringColumns_Delete.E Lt(final String value) { boundValues.add(value); encodedValues.add(meta.value.encodeFromJava(value, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lt("value", QueryBuilder.bindMarker("value"))); return EntityWithClusteringColumns_Delete.E.this; }
/** * Generate an ... <strong>IF fullIndexOnCollection > ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexIndices_Delete.E Gt(final Set<String> fullIndexOnCollection) { boundValues.add(fullIndexOnCollection); encodedValues.add(meta.fullIndexOnCollection.encodeFromJava(fullIndexOnCollection, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gt("fullindexoncollection", QueryBuilder.bindMarker("fullindexoncollection"))); return EntityWithComplexIndices_Delete.E.this; }
/** * Generate an ... <strong>IF collectionIndex = ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexIndices_Delete.E Eq(final List<String> collectionIndex) { boundValues.add(collectionIndex); encodedValues.add(meta.collectionIndex.encodeFromJava(collectionIndex, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.eq("collectionindex", QueryBuilder.bindMarker("collectionindex"))); return EntityWithComplexIndices_Delete.E.this; }
/** * Generate an ... <strong>IF simpleIndex < ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexIndices_Delete.E Lt(final String simpleIndex) { boundValues.add(simpleIndex); encodedValues.add(meta.simpleIndex.encodeFromJava(simpleIndex, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lt("simpleindex", QueryBuilder.bindMarker("simpleindex"))); return EntityWithComplexIndices_Delete.E.this; }
/** * Generate an ... <strong>IF simpleIndex = ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexIndices_Delete.E Eq(final String simpleIndex) { boundValues.add(simpleIndex); encodedValues.add(meta.simpleIndex.encodeFromJava(simpleIndex, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.eq("simpleindex", QueryBuilder.bindMarker("simpleindex"))); return EntityWithComplexIndices_Delete.E.this; }
/** * Generate an ... <strong>IF list <= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithBeanValidation_Delete.E Lte(final List<String> list) { boundValues.add(list); encodedValues.add(meta.list.encodeFromJava(list, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lte("list", QueryBuilder.bindMarker("list"))); return EntityWithBeanValidation_Delete.E.this; }
/** * Generate an ... <strong>IF tuple != ?</strong> */ @SuppressWarnings("static-access") public final EntityWithComplexTuple_Delete.E NotEq(final Tuple2<Integer, Map<Integer, List<String>>> tuple) { boundValues.add(tuple); encodedValues.add(meta.tuple.encodeFromJava(tuple, Optional.of(cassandraOptions))); where.onlyIf(NotEq.of("tuple", QueryBuilder.bindMarker("tuple"))); return EntityWithComplexTuple_Delete.E.this; } }
/** * Generate an ... <strong>IF udt <= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Lte(final UDTWithNoKeyspace udt) { boundValues.add(udt); encodedValues.add(meta.udt.encodeFromJava(udt, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lte("\"udtWithNoKeyspace\"", QueryBuilder.bindMarker("\"udtWithNoKeyspace\""))); return EntityWithCaseSensitivePK_Delete.E.this; }
/** * Generate an ... <strong>IF set <= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Lte(final Set<String> set) { boundValues.add(set); encodedValues.add(meta.set.encodeFromJava(set, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lte("\"setString\"", QueryBuilder.bindMarker("\"setString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }
/** * Generate an ... <strong>IF set > ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Gt(final Set<String> set) { boundValues.add(set); encodedValues.add(meta.set.encodeFromJava(set, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gt("\"setString\"", QueryBuilder.bindMarker("\"setString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }
/** * Generate an ... <strong>IF list > ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Gt(final List<String> list) { boundValues.add(list); encodedValues.add(meta.list.encodeFromJava(list, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gt("\"listString\"", QueryBuilder.bindMarker("\"listString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }
/** * Generate an ... <strong>IF list = ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Eq(final List<String> list) { boundValues.add(list); encodedValues.add(meta.list.encodeFromJava(list, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.eq("\"listString\"", QueryBuilder.bindMarker("\"listString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }