cassandra - Using Custom Classes in Collection Types using DataStax's Java Driver -


is there way use our types (classes provide) in the collection types provide datastax java driver through boundstatement.setset(..) method without using user defined types? perhaps object mapping api?

and if so, when create table should use type in set (in other words: set<????>)?

we're using datastax java driver v2.1.5 connected dse v4.6.0 (cassandra 2.0.11.83).

here's example illustrate:

create table teams (uid text primary key, players set<????>); 

our type:

public class player {    private string name;    public player(string name) { this.name = name;   }    public string getname() { return name;   }       public void setname(string name) { this.name = name; }  } 

test:

public void testsets(){      set<player> players = new hashset<>();      players.add(new player("nick"));     players.add(new player("paul"));     players.add(new player("scott"));      preparedstatement statement = session.prepare("insert teams (uid, players) values (?,?);");      boundstatement boundstatement = new boundstatement(statement);      boundstatement.setstring("uid", ...);     boundstatement.setset("players", players);      session.execute(boundstatement);  } 

unfortunately cannot today driver or object mapping api yet. there outstanding issue (java-722) opened today handle , other mapping related inadequacies (related issues linked in issue) covered in next release (2.1.6) of driver.

it may worth taking @ achilles supports through type transformer.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -