public final 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(akka.actor.ActorSystem system) |
CassandraSession(akka.actor.ActorSystem system,
akka.persistence.cassandra.session.CassandraSessionSettings settings,
scala.concurrent.ExecutionContext executionContext) |
Modifier and Type | Method and Description |
---|---|
CompletionStage<akka.Done> |
executeCreateTable(String stmt)
See Creating a table.
|
CompletionStage<akka.Done> |
executeWrite(com.datastax.driver.core.Statement stmt)
Execute one statement.
|
CompletionStage<akka.Done> |
executeWrite(String stmt,
Object... bindValues)
Prepare, bind and execute one statement in one go.
|
CompletionStage<akka.Done> |
executeWrite(String stmt,
scala.collection.Seq<Object> bindValues)
Prepare, bind and execute one statement in one go.
|
CompletionStage<akka.Done> |
executeWriteBatch(com.datastax.driver.core.BatchStatement batch)
Execute several statements in a batch.
|
CompletionStage<com.datastax.driver.core.PreparedStatement> |
prepare(String stmt)
Create a
PreparedStatement that can be bound and used in
executeWrite or select multiple times. |
akka.persistence.cassandra.session.scaladsl.CassandraSession |
scalaDelegate()
Internal API
|
akka.stream.javadsl.Source<com.datastax.driver.core.Row,akka.NotUsed> |
select(com.datastax.driver.core.Statement stmt)
Execute a select statement.
|
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.
|
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.
|
CompletionStage<List<com.datastax.driver.core.Row>> |
selectAll(com.datastax.driver.core.Statement stmt)
Execute a select statement.
|
CompletionStage<List<com.datastax.driver.core.Row>> |
selectAll(String stmt,
Object... bindValues)
Prepare, bind and execute a select statement in one go.
|
CompletionStage<List<com.datastax.driver.core.Row>> |
selectAll(String stmt,
scala.collection.Seq<Object> bindValues)
Prepare, bind and execute a select statement in one go.
|
CompletionStage<Optional<com.datastax.driver.core.Row>> |
selectOne(com.datastax.driver.core.Statement stmt)
Execute a select statement that returns one row.
|
CompletionStage<Optional<com.datastax.driver.core.Row>> |
selectOne(String stmt,
Object... bindValues)
Prepare, bind and execute a select statement that returns one row.
|
CompletionStage<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.
|
CompletionStage<com.datastax.driver.core.Session> |
underlying()
The
Session of the underlying
Datastax Java Driver. |
public CassandraSession(akka.actor.ActorSystem system, akka.persistence.cassandra.session.CassandraSessionSettings settings, scala.concurrent.ExecutionContext executionContext)
public CassandraSession(akka.actor.ActorSystem system)
public 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 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 CompletionStage<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 CompletionStage<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 akka.persistence.cassandra.session.scaladsl.CassandraSession scalaDelegate()
public 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 CompletionStage<akka.Done> executeCreateTable(String stmt)
The returned CompletionStage
is completed when the table has been created,
or if the statement fails.
public CompletionStage<com.datastax.driver.core.PreparedStatement> prepare(String stmt)
PreparedStatement
that can be bound and used in
executeWrite
or select
multiple times.public 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 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 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 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 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 CompletionStage<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 CompletionStage<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 CompletionStage<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 CompletionStage<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.