Cassandra UUID查询问题

时间:2014-11-03 15:22:29

标签: java cassandra

Cassandra有以下可能吗?我想从表中获取所有UUID的列表,但我一直在收到错误。以下是有问题的代码:

@Query("SELECT id FROM table")
public Result<UUID> getIds();

以下是错误:

Caused by: java.lang.RuntimeException: Error preparing queries for accessor DeviceAccessor
    at com.datastax.driver.mapping.AccessorMapper.prepare(AccessorMapper.java:48)
    at com.datastax.driver.mapping.MappingManager.getAccessor(MappingManager.java:156)
    at com.datastax.driver.mapping.MappingManager.createAccessor(MappingManager.java:109)
    at com.tmp.whatever.persistence.DevicePersistenceHandler.init(DevicePersistenceHandler.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
    ... 41 more
Caused by: java.lang.RuntimeException: Cannot map return to class class com.datastax.driver.mapping.Result
    at com.datastax.driver.mapping.MethodMapper.mapType(MethodMapper.java:118)
    at com.datastax.driver.mapping.MethodMapper.prepare(MethodMapper.java:93)
    at com.datastax.driver.mapping.AccessorMapper.prepare(AccessorMapper.java:46)
    ... 51 more
Caused by: java.lang.IllegalArgumentException: @Table annotation was not found on type java.util.UUID
    at com.datastax.driver.mapping.AnnotationParser.getTypeAnnotation(AnnotationParser.java:292)
    at com.datastax.driver.mapping.AnnotationParser.parseEntity(AnnotationParser.java:49)
    at com.datastax.driver.mapping.MappingManager.getMapper(MappingManager.java:119)
    at com.datastax.driver.mapping.MappingManager.mapper(MappingManager.java:76)
    at com.datastax.driver.mapping.MethodMapper.mapType(MethodMapper.java:116)
    ... 53 more

我是Cassandra的新手,这是我第一次尝试没有任何训练轮的查询,所以有可能我错过了一些明显的东西。如果有帮助,Result类来自com.datastax.driver.mapping。

CREATE TABLE IF NOT EXISTS devices (
  id uuid,
  name text,
  description text,
  device_type text,
  address text,
  port int,
  ssl boolean,
  credentials uuid,
  PRIMARY KEY (id)
);

1 个答案:

答案 0 :(得分:0)

Datastax的Acessor接口中的方法可以返回void或类的实例(或Result)