I have a User Defined Type in Cassandra which I created using following syntax in CQLSH :
CREATE TYPE order_items (
qty int,
name text,
milk_type text,
size text,
price decimal
);
Now in my table, I am storing a list of the type "order_items" so I can store multiple items for one object.
Something like this :
CREATE TABLE order (
order_id uuid PRIMARY KEY,
amount decimal,
location text,
items list<frozen<order_items>>,
status text,
message text
);
If I want to store a record using CQLSH, I can do so with the following syntax,
INSERT INTO order (order_id,amount,location,items,status,message) VALUES
(e7ae5cf3-d358-4d99-b900-85902fda9bb0, 5, 'San Jose',[{qty:2,name:'mocha',milk_type:'whole',size:'small',price:2.5}], 'PLACED','order is in process');
but when I try to do the same using the DataStax Java driver for cassandra, I am not able to provide the user defined type as a list of objects. I could only come up with a string syntax, but obviously it is throwing the above error.
I have tried referring the datastax documentation, but apparently it is still a work in progress : http://docs.datastax.com/en/developer/java-driver/3.1/manual/udts/
Here is my Java syntax:
session.execute(insertorderPstmt.bind(UUID.randomUUID(),new BigDecimal("4"),"Santa Clara","[{qty:2,name:'mocha',milk_type:'whole',size:'small',price:2.5}]","PLACED","in process"));
and the error:
Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 3, column is a list but class java.lang.String provided
Is there anyone who has been able to store custom type lists using java driver?