public interface Relation extends CqlSnippet
To build instances of this type, use the factory methods, such as column, token, etc.
They are used as arguments to the where method, for
example:
selectFrom("foo").all().where(Relation.column("k").isEqualTo(literal(1)))
// SELECT * FROM foo WHERE k=1
There are also shortcuts in the fluent API when you build a statement, for example:
selectFrom("foo").all().whereColumn("k").isEqualTo(literal(1))
// SELECT * FROM foo WHERE k=1
| Modifier and Type | Method and Description |
|---|---|
static ColumnRelationBuilder<Relation> |
column(com.datastax.oss.driver.api.core.CqlIdentifier id)
Builds a relation testing a column.
|
static ColumnRelationBuilder<Relation> |
column(String name)
Shortcut for
column(CqlIdentifier.fromCql(name)) |
static MultiColumnRelationBuilder<Relation> |
columnIds(Iterable<com.datastax.oss.driver.api.core.CqlIdentifier> identifiers)
Builds a multi-column relation, as in
WHERE (c1, c2, c3) IN .... |
static MultiColumnRelationBuilder<Relation> |
columns(com.datastax.oss.driver.api.core.CqlIdentifier... identifiers)
Var-arg equivalent of
columnIds(Iterable). |
static MultiColumnRelationBuilder<Relation> |
columns(Iterable<String> names)
Equivalent of
columnIds(Iterable) with raw strings; the names are converted with
CqlIdentifier.fromCql(String). |
static MultiColumnRelationBuilder<Relation> |
columns(String... names)
Var-arg equivalent of
columns(Iterable). |
static Relation |
customIndex(com.datastax.oss.driver.api.core.CqlIdentifier indexId,
Term expression)
Builds a relation on a custom index.
|
static Relation |
customIndex(String indexName,
Term expression)
|
boolean |
isIdempotent()
Whether this relation is idempotent.
|
static ColumnComponentRelationBuilder<Relation> |
mapValue(com.datastax.oss.driver.api.core.CqlIdentifier columnId,
Term index)
Builds a relation testing a value in a map (Cassandra 4 and above).
|
static ColumnComponentRelationBuilder<Relation> |
mapValue(String columnName,
Term index)
Shortcut for
mapValue(CqlIdentifier.fromCql(columnName),
index) |
static TokenRelationBuilder<Relation> |
token(com.datastax.oss.driver.api.core.CqlIdentifier... identifiers)
Var-arg equivalent of
tokenFromIds(Iterable). |
static TokenRelationBuilder<Relation> |
token(Iterable<String> names)
Equivalent of
tokenFromIds(Iterable) with raw strings; the names are converted with
CqlIdentifier.fromCql(String). |
static TokenRelationBuilder<Relation> |
token(String... names)
Var-arg equivalent of
token(Iterable). |
static TokenRelationBuilder<Relation> |
tokenFromIds(Iterable<com.datastax.oss.driver.api.core.CqlIdentifier> identifiers)
Builds a relation testing a token generated from a set of columns.
|
appendTo@NonNull static ColumnRelationBuilder<Relation> column(@NonNull com.datastax.oss.driver.api.core.CqlIdentifier id)
This must be chained with an operator call, for example:
Relation r = Relation.column("k").isEqualTo(bindMarker());
@NonNull static ColumnRelationBuilder<Relation> column(@NonNull String name)
column(CqlIdentifier.fromCql(name))@NonNull static ColumnComponentRelationBuilder<Relation> mapValue(@NonNull com.datastax.oss.driver.api.core.CqlIdentifier columnId, @NonNull Term index)
@NonNull static ColumnComponentRelationBuilder<Relation> mapValue(@NonNull String columnName, @NonNull Term index)
mapValue(CqlIdentifier.fromCql(columnName),
index)@NonNull static TokenRelationBuilder<Relation> tokenFromIds(@NonNull Iterable<com.datastax.oss.driver.api.core.CqlIdentifier> identifiers)
@NonNull static TokenRelationBuilder<Relation> token(@NonNull com.datastax.oss.driver.api.core.CqlIdentifier... identifiers)
tokenFromIds(Iterable).@NonNull static TokenRelationBuilder<Relation> token(@NonNull Iterable<String> names)
tokenFromIds(Iterable) with raw strings; the names are converted with
CqlIdentifier.fromCql(String).@NonNull static TokenRelationBuilder<Relation> token(@NonNull String... names)
token(Iterable).@NonNull static MultiColumnRelationBuilder<Relation> columnIds(@NonNull Iterable<com.datastax.oss.driver.api.core.CqlIdentifier> identifiers)
WHERE (c1, c2, c3) IN ....@NonNull static MultiColumnRelationBuilder<Relation> columns(@NonNull com.datastax.oss.driver.api.core.CqlIdentifier... identifiers)
columnIds(Iterable).@NonNull static MultiColumnRelationBuilder<Relation> columns(@NonNull Iterable<String> names)
columnIds(Iterable) with raw strings; the names are converted with
CqlIdentifier.fromCql(String).@NonNull static MultiColumnRelationBuilder<Relation> columns(@NonNull String... names)
columns(Iterable).@NonNull static Relation customIndex(@NonNull com.datastax.oss.driver.api.core.CqlIdentifier indexId, @NonNull Term expression)
@NonNull static Relation customIndex(@NonNull String indexName, @NonNull Term expression)
boolean isIdempotent()
That is, whether it always selects the same rows when used multiple times. For example,
WHERE c=1 is idempotent, WHERE c=now() isn't.
This is used internally by the query builder to compute the Request.isIdempotent()
flag on the UPDATE and DELETE statements generated by BuildableQuery.build() (this is
not relevant for SELECT statement, which are always idempotent). If a term is ambiguous (for
example a raw snippet or a call to a user function in the right operands), the builder is
pessimistic and assumes the term is not idempotent.
Copyright © 2017–2022. All rights reserved.