When I do a INSERT things go well:
String insertText = "INSERT INTO alpha_screen (alpha, screen) VALUES (?,?)";
PreparedStatement preparedStatement = InsertWordCount.PrepareText(insertText);
BoundStatement boundStatement = preparedStatement.bind(keyvalue, newword); //INSERT positions
getSession().execute(boundStatement);
cqlsh> SELECT * FROM rant.alpha_screen; ==> The INSERTS are done as expected.
alpha | screen
-------+--------------
a | ['aboard']
c | ['checking']
p | ['pull']
r | ['rotting']
t | ['time']
Not so much with PrepareText UPDATE:
String insertText = "UPDATE alpha_screen SET screen = screen + ['newword'] WHERE alpha = 'keyvalue' VALUES (?, ?)";
PreparedStatement preparedStatement = InsertWordCount.PrepareText(insertText);
BoundStatement boundStatement = preparedStatement.bind(newword, keyvalue); // UPDATE positions
getSession().execute(boundStatement);
com.datastax.driver.core.exceptions.SyntaxError: line 1:79 missing EOF at 'VALUES' (...] WHERE alpha = 'keyvalue' [VALUES] (...)
at com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:35)
at com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:289)
at com.datastax.driver.core.AbstractSession.prepare(AbstractSession.java:79)
at playlist.model.InsertWordCount.PrepareText(InsertWordCount.java:13)
at playlist.model.CountDAO.screenWord(CountDAO.java:99)
It looks like it should work for this example in the documentation:
Append an element to the list by switching the order of the new element data and the list name in the UPDATE command.
UPDATE users
SET top_places = top_places + [ 'mordor' ] WHERE user_id = 'frodo';
In fact it works just fine without VALUES:
String insertText = "UPDATE alpha_screen SET screen = screen + ['twoword'] WHERE alpha = 'keyvalue' ";
PreparedStatement preparedStatement = InsertWordCount.PrepareText(insertText);
BoundStatement boundStatement = preparedStatement.bind(); // No VALUES
getSession().execute(boundStatement);
cqlsh> SELECT * FROM rant.alpha_screen;
alpha | screen
----------+-----------------------------------
a | ['aboard']
c | ['checking']
p | ['pull']
keyvalue | ['newword', 'oneword', 'twoword']
r | ['rotting']
t | ['time']