public class Insert extends BuiltStatement
| Modifier and Type | Class and Description |
|---|---|
static class |
Insert.Options
The options of an INSERT statement.
|
idempotent, NULL_PAYLOAD_VALUE| Modifier and Type | Method and Description |
|---|---|
Insert |
ifNotExists()
Sets the 'IF NOT EXISTS' option for this INSERT statement.
|
Insert |
json(Object json)
Inserts the provided object, using the {@code INSERT INTO ...
|
Insert.Options |
using()
Returns the options for this INSERT statement.
|
Insert.Options |
using(Using using)
Adds a new options for this INSERT statement.
|
Insert |
value(String name,
Object value)
Adds a column/value pair to the values inserted by this INSERT statement.
|
Insert |
values(List<String> names,
List<Object> values)
Adds multiple column/value pairs to the values inserted by this INSERT statement.
|
Insert |
values(String[] names,
Object[] values)
Adds multiple column/value pairs to the values inserted by this INSERT statement.
|
escapeId, getKeyspace, getNamedValues, getObject, getObject, getQueryString, getRoutingKey, getValues, hasValues, isIdempotent, setForceNoValues, toString, usesNamedValuesgetQueryString, hasValuesdisableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getOutgoingPayload, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, isBatchIdempotent, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setIdempotent, setOutgoingPayload, setPagingState, setPagingState, setPagingStateUnsafe, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevelpublic Insert value(String name, Object value)
name - the name of the column to insert/update.value - the value to insert/update for name.IllegalStateException - if this method is called and the json(Object)
method has been called before, because it's not possible
to mix INSERT JSON syntax with regular INSERT syntax.public Insert values(String[] names, Object[] values)
names - a list of column names to insert/update.values - a list of values to insert/update. The ith
value in values will be inserted for the ith column
in names.IllegalArgumentException - if names.length != values.length.IllegalStateException - if this method is called and the json(Object)
method has been called before, because it's not possible
to mix INSERT JSON syntax with regular INSERT syntax.public Insert values(List<String> names, List<Object> values)
names - a list of column names to insert/update.values - a list of values to insert/update. The ith
value in values will be inserted for the ith column
in names.IllegalArgumentException - if names.size() != values.size().IllegalStateException - if this method is called and the json(Object)
method has been called before, because it's not possible
to mix INSERT JSON syntax with regular INSERT syntax.public Insert json(Object json)
INSERT INTO ... JSON syntax introduced
in Cassandra 2.2.
With INSERT statements, the new JSON keyword can be used to enable inserting a JSON
structure as a single row.
The provided object can be of the following types:
SELECT JSON statement on the same table.
Note that it is not possible to insert function calls nor bind markers in a JSON string.bind marker. In this case, the statement is meant to be prepared
and no JSON string will be appended to the query string, only a bind marker for the whole JSON parameter.codec is registered with the
CodecRegistry in use. This allows the usage of JSON libraries, such
as the Java API for JSON processing,
the popular Jackson library, or
Google's Gson library, for instance.
insertInto("mytable").json("{\"\\\"myKey\\\"\": 0, \"value\": 0}");
This will produce the following CQL:
INSERT INTO mytable JSON '{"\"myKey\"": 0, "value": 0}';
foo"'bar should be inserted in the JSON string
as "foo\"''bar".
NULL value
(which will result in a tombstone being created).json - the JSON string, or a bind marker, or a JSON object handled by a specific codec.IllegalStateException - if this method is called and any of the value or values
methods have been called before, because it's not possible
to mix INSERT JSON syntax with regular INSERT syntax.public Insert.Options using(Using using)
using - the option to add.public Insert.Options using()
Insert.Options.and(Using) to add options.public Insert ifNotExists()
Statement.isIdempotent()
for more information.Copyright © 2012–2017. All rights reserved.