Java Cassandra UDT嵌套集InvalidTypeExeception
我正在Cassandra 2.1中试验UDT,并与InvalidTypeExeception作斗争 我将表格设置为:Java Cassandra UDT嵌套集InvalidTypeExeception,java,cassandra,datastax,user-defined-types,Java,Cassandra,Datastax,User Defined Types,我正在Cassandra 2.1中试验UDT,并与InvalidTypeExeception作斗争 我将表格设置为: session.execute("CREATE TYPE mykeyspace.address (" + " street text," + " city text," + " zip_code int," + "
session.execute("CREATE TYPE mykeyspace.address (" +
" street text," +
" city text," +
" zip_code int," +
" phones set<text>" +
");"
);
session.execute("CREATE TYPE mykeyspace.fullname (" +
" firstname text," +
" lastname text" +
");"
);
session.execute(
"CREATE TABLE mykeyspace.users (" +
" id uuid PRIMARY KEY," +
" name frozen <fullname>," +
" direct_reports set<frozen <fullname>>," +
" addresses map<text, frozen <address>>" +
"); ");
我只是对我做错了什么和我遗漏了什么感到困惑,我确信这是显而易见的,但我无法理解
谢谢 这将是驱动程序中的一个bug。如果您已确保使用的是最新发布的驱动程序版本(以确保尚未修复),请在2.1.4和2.1.3上测试的。上报告此问题。我开了一张罚单,我也面临着同样的错误
PreparedStatement statement = session.prepare("INSERT INTO mykeyspace.users (id, name, addresses) VALUES (?, ?, ?);");
UserType fullNameType = session.getCluster().getMetadata().getKeyspace("mykeyspace").getUserType("fullname");
UserType addresType = session.getCluster().getMetadata().getKeyspace("mykeyspace").getUserType("address");
BoundStatement boundStatement = new BoundStatement(statement);
UUID uuid = UUID.randomUUID();
UDTValue name = fullNameType.newValue().setString("firstname", "john").setString("lastname", "smith");
UDTValue address = addresType.newValue()
.setString("street", "1 long st")
.setString("city", "sydney")
.setInt("zip_code", 2000)
.setSet("phones",ImmutableSet.of("123", "456", "789")); // ERROR THROWN HERE
Map<String, UDTValue> addresses = new HashMap<String, UDTValue>();
addresses.put("home", address);
session.execute(boundStatement.bind(
uuid,
name,
addresses
));
Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException:
Column phones is of type 'org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type))', cannot set to a set