【发布时间】:2015-09-10 20:52:01
【问题描述】:
这是我的 CQL 表
CREATE TYPE ks_demo.location (
lat float,
lon float,
locName text,
city text,
state text,
country text,
pin int
);
create table publishMsg
(
rowKey uuid,
msgId timeuuid,
postedBy text,
postedById uuid,
title text,
details text,
tags set<text>,
location frozen<location>,
blocked boolean,
anonymous boolean,
hasPhotos boolean,
PRIMARY KEY(rowKey, msgId)
)
create table publishMsg_by_user
(
userId uuid,
msgId timeuuid,
postedBy text,
title text,
details text,
tags set<text>,
location frozen<location>,
blocked boolean,
anonymous boolean,
hasPhotos boolean,
PRIMARY KEY(rowKey, msgId)
)
这里是datastax java查询
Select.Where query = QueryBuilder.select().column("userId").column("msgId")
.column("location.city")
.from(AppConstants.KEYSPACE, "publishMsg_by_user")
.where(QueryBuilder.eq("userId",userId));
如果我这样做了
ResultSet execute = session.execute(query);
Iterator<Row> iterator = execute.iterator();
while(iterator.hasNext())
{
Row row = iterator.next();
row.getString("location.city")
}
row.getString("location.city")
它正在显示
Exception in thread "main" java.lang.IllegalArgumentException: location.city is not a column defined in this metadata
【问题讨论】:
-
你用的是什么版本的驱动?
-
@manish 您的查询提到了“userId”列,但它不在表定义中。应该吗?
-
您能否发布
publishMsg_by_user的CQL 而不仅仅是publishMsg?我们这里没有所有信息。
标签: java cassandra datastax cql3 datastax-java-driver