public abstract class CassandraSession
extends Object
The configured keyspace is automatically created if it doesn't already exists. The keyspace is also set as the current keyspace, i.e. it doesn't have to be qualified in the statements.
All methods are non-blocking.
Constructor and Description |
---|
CassandraSession() |
Modifier and Type | Method and Description |
---|---|
abstract java.util.concurrent.CompletionStage<akka.Done> |
executeCreateTable(String stmt)
See Creating a table.
|
abstract java.util.concurrent.CompletionStage<akka.Done> |
executeWrite(com.datastax.driver.core.Statement stmt)
Execute one statement.
|
abstract java.util.concurrent.CompletionStage<akka.Done> |
executeWrite(String stmt,
Object... bindValues)
Prepare, bind and execute one statement in one go.
|
abstract java.util.concurrent.CompletionStage<akka.Done> |
executeWrite(String stmt,
scala.collection.Seq<Object> bindValues)
Prepare, bind and execute one statement in one go.
|
abstract java.util.concurrent.CompletionStage<akka.Done> |
executeWriteBatch(com.datastax.driver.core.BatchStatement batch)
Execute several statements in a batch.
|
abstract java.util.concurrent.CompletionStage<com.datastax.driver.core.PreparedStatement> |
prepare(String stmt)
Create a
PreparedStatement that can be bound and used in
executeWrite or select multiple times. |
abstract akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> |
select(com.datastax.driver.core.Statement stmt)
Execute a select statement.
|
abstract akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> |
select(String stmt,
Object... bindValues)
Prepare, bind and execute a select statement in one go.
|
abstract akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> |
select(String stmt,
scala.collection.Seq<Object> bindValues)
Prepare, bind and execute a select statement in one go.
|
abstract java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.Row>> |
selectAll(com.datastax.driver.core.Statement stmt)
Execute a select statement.
|
abstract java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.Row>> |
selectAll(String stmt,
Object... bindValues)
Prepare, bind and execute a select statement in one go.
|
abstract java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.Row>> |
selectAll(String stmt,
scala.collection.Seq<Object> bindValues)
Prepare, bind and execute a select statement in one go.
|
abstract java.util.concurrent.CompletionStage<java.util.Optional<com.datastax.driver.core.Row>> |
selectOne(com.datastax.driver.core.Statement stmt)
Execute a select statement that returns one row.
|
abstract java.util.concurrent.CompletionStage<java.util.Optional<com.datastax.driver.core.Row>> |
selectOne(String stmt,
Object... bindValues)
Prepare, bind and execute a select statement that returns one row.
|
abstract java.util.concurrent.CompletionStage<java.util.Optional<com.datastax.driver.core.Row>> |
selectOne(String stmt,
scala.collection.Seq<Object> bindValues)
Prepare, bind and execute a select statement that returns one row.
|
abstract java.util.concurrent.CompletionStage<com.datastax.driver.core.Session> |
underlying()
The
Session of the underlying
Datastax Java Driver. |
public abstract java.util.concurrent.CompletionStage<akka.Done> executeWrite(String stmt, Object... bindValues)
See Inserting and updating data.
The configured write consistency level is used.
The returned CompletionStage
is completed when the statement has been
successfully executed, or if it fails.
public abstract akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> select(String stmt, Object... bindValues)
See Querying tables.
The configured read consistency level is used.
You can return this Source
as a response in a ServiceCall
and the elements will be streamed to the client.
Otherwise you have to connect a Sink
that consumes the messages from
this Source
and then run
the stream.
public abstract java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.Row>> selectAll(String stmt, Object... bindValues)
LIMIT
clause.
Otherwise you should use the select
method that returns a Source
.
The configured read consistency level is used.
The returned CompletionStage
is completed with the found rows.
public abstract java.util.concurrent.CompletionStage<java.util.Optional<com.datastax.driver.core.Row>> selectOne(String stmt, Object... bindValues)
The configured read consistency level is used.
The returned CompletionStage
is completed with the first row,
if any.
public abstract java.util.concurrent.CompletionStage<com.datastax.driver.core.Session> underlying()
Session
of the underlying
Datastax Java Driver.
Can be used in case you need to do something that is not provided by the
API exposed by this class. Be careful to not use blocking calls.public abstract java.util.concurrent.CompletionStage<akka.Done> executeCreateTable(String stmt)
The returned CompletionStage
is completed when the table has been created,
or if the statement fails.
public abstract java.util.concurrent.CompletionStage<com.datastax.driver.core.PreparedStatement> prepare(String stmt)
PreparedStatement
that can be bound and used in
executeWrite
or select
multiple times.public abstract java.util.concurrent.CompletionStage<akka.Done> executeWriteBatch(com.datastax.driver.core.BatchStatement batch)
prepare(java.lang.String)
the
statements and bind its parameters.
See Batching data insertion and updates.
The configured write consistency level is used if a specific consistency
level has not been set on the BatchStatement
.
The returned CompletionStage
is completed when the batch has been
successfully executed, or if it fails.
public abstract java.util.concurrent.CompletionStage<akka.Done> executeWrite(com.datastax.driver.core.Statement stmt)
prepare(java.lang.String)
the
statement and bind its parameters.
See Inserting and updating data.
The configured write consistency level is used if a specific consistency
level has not been set on the Statement
.
The returned CompletionStage
is completed when the statement has been
successfully executed, or if it fails.
public abstract java.util.concurrent.CompletionStage<akka.Done> executeWrite(String stmt, scala.collection.Seq<Object> bindValues)
See Inserting and updating data.
The configured write consistency level is used.
The returned CompletionStage
is completed when the statement has been
successfully executed, or if it fails.
public abstract akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> select(com.datastax.driver.core.Statement stmt)
prepare(java.lang.String)
the
statement and bind its parameters.
See Querying tables.
The configured read consistency level is used if a specific consistency
level has not been set on the Statement
.
You can return this Source
as a response in a ServiceCall
and the elements will be streamed to the client.
Otherwise you have to connect a Sink
that consumes the messages from
this Source
and then run
the stream.
public abstract akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> select(String stmt, scala.collection.Seq<Object> bindValues)
See Querying tables.
The configured read consistency level is used.
You can return this Source
as a response in a ServiceCall
and the elements will be streamed to the client.
Otherwise you have to connect a Sink
that consumes the messages from
this Source
and then run
the stream.
public abstract java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.Row>> selectAll(com.datastax.driver.core.Statement stmt)
prepare(java.lang.String)
the statement and
bind its parameters. Only use this method when you know that the result
is small, e.g. includes a LIMIT
clause. Otherwise you should use the
select
method that returns a Source
.
The configured read consistency level is used if a specific consistency
level has not been set on the Statement
.
The returned CompletionStage
is completed with the found rows.
public abstract java.util.concurrent.CompletionStage<java.util.List<com.datastax.driver.core.Row>> selectAll(String stmt, scala.collection.Seq<Object> bindValues)
LIMIT
clause.
Otherwise you should use the select
method that returns a Source
.
The configured read consistency level is used.
The returned CompletionStage
is completed with the found rows.
public abstract java.util.concurrent.CompletionStage<java.util.Optional<com.datastax.driver.core.Row>> selectOne(com.datastax.driver.core.Statement stmt)
prepare(java.lang.String)
the
statement and bind its parameters.
The configured read consistency level is used if a specific consistency
level has not been set on the Statement
.
The returned CompletionStage
is completed with the first row,
if any.
public abstract java.util.concurrent.CompletionStage<java.util.Optional<com.datastax.driver.core.Row>> selectOne(String stmt, scala.collection.Seq<Object> bindValues)
The configured read consistency level is used.
The returned CompletionStage
is completed with the first row,
if any.