I am using datastax' Cassandra Java driver. My Cassandra supports CQL 2 only.
I have a prepared INSERT statement that needs to accept a list of maps.
This is my schema:
CREATE TYPE test.snap_guid (
l bigint,
h bigint
);
CREATE TABLE test.t (
id bigint,
snap list<frozen<snap_guid>>,
PRIMARY KEY ((id))
)
This is the prepared statement:
PreparedStatement mysttmt = <client>.prepare("INSERT INTO test.t (id, snap) VALUES (?, ?)");
I know that in order to bind collections to the prepared statement I need to create a collection, and bind it. I cannot put the collection brackets in the prepared query. For instance (for list of text):
ArrayList<String> snaps = new ArrayList<>();
snaps.add("AEF34GF665");
// INSERT INTO test.t (id, snap) VALUES (?, ?)
BoundStatement bs = mysttmt.bind(12, snaps);
My question is: how do I bind a list of maps? How can I create a query like the next one?
INSERT INTO test.t (id, snap) VALUES (12, [{l:10,h:50}])
// I know it is impossible to create the following prepared statement:
INSERT INTO test.t (id, snap) VALUES (?, [{l:?,h:?}])
// The list of maps has to be a single bound variable... how???
INSERT INTO test.t (id, snap) VALUES (?, ?)