Cassandra - unable to parse list of Tuple with Java driver -
i trying access tuple data structure have stored in cassandra mapper. but, unable to. haven't found example online.
this table , data have created.
cqlsh:test> create table test.test_nested (id varchar primary key, address_mapping list<frozen<tuple<text,text>>>); cqlsh:test> insert test.test_nested (id, address_mapping) values ('12345', [('adress 1', 'pin1'), ('adress 2', 'pin2')]); cqlsh:test> cqlsh:test> select * test.test_nested; id | address_mapping -------+---------------------------------------------- 12345 | [('adress 1', 'pin1'), ('adress 2', 'pin2')] (1 rows)
my mapped class(using lombok builder, getter, setter):
@builder @table(keyspace = "test", name = "test_nested") public class testnested { @partitionkey @column(name = "id") @getter @setter private string id; @column(name = "address_mapping") @frozen @getter @setter private list<object> address_mapping; }
my mapper class: public class testnestedstore {
private final mapper<testnested> mapper; public testnestedstore(mapper<testnested> mapper) { this.mapper = mapper; } public void insert(testnested userdropdata) { mapper.save(userdropdata); } public void remove(string id) { mapper.delete(id); } public testnested findbyuserid(string id) { return mapper.get(id); } public listenablefuture<testnested> findbyuseridasync(string id) { return mapper.getasync(id); } }
i trying access data in test method follows:
@test public void testconnection2(){ mappingmanager manager = new mappingmanager(scylladbconnector.getsession()); mapper<testnested> mapper = manager.mapper(testnested.class); testnestedstore testnestedstore = new testnestedstore(mapper); listenablefuture<testnested> fut = testnestedstore.findbyuseridasync("12345"); futures.addcallback(fut, new futurecallback<testnested>() { @override public void onsuccess(testnested testnested) { } @override public void onfailure(throwable throwable) { system.out.println("call failed"); } }); }
bit, unable access tuple. error:
java.lang.illegalargumentexception: error while checking frozen types on field address_mapping of entity com.example.model.testnested: expected list not frozen frozen @ com.datastax.driver.mapping.annotationchecks.validateannotations(annotationchecks.java:73) @ com.datastax.driver.mapping.annotationparser.parseentity(annotationparser.java:81) @ com.datastax.driver.mapping.mappingmanager.getmapper(mappingmanager.java:148) @ com.datastax.driver.mapping.mappingmanager.mapper(mappingmanager.java:105)
i have tried private list<tuplevalue> address_mapping;
. of no use!
how access tuple values through object mapper of cassandra?
Comments
Post a Comment