Skip to content
Advertisement

cannot insert list of maps to Apache Cassandra

This is my schema

JavaScript

insert query generated by java is in this form

JavaScript

issue is with ‘=’ sign in the map objects in the list of maps. How can I insert it correctly? in java.

Advertisement

Answer

map value should be specified as {key1:val1, key2:val2} (see docs), in your case it should be a

JavaScript

but really, you shouldn’t generate literal query yourself, as it could be a complex task – you need to handle quotes correctly, etc.

More appropriate will be to use prepared statements, and bind values – in this case, all syntax will be handled by driver.

Another possibility is to use Object Mapper (doc for driver 3.x, driver 4.x) – in this case, you may work with rows in the table using the Java objects, all conversion will be handled by driver as well.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement