1

春季启动数据卡桑德拉

CQL:

CREATE TABLE device_data (
    device_id uuid,
    time timeuuid,
    unit text,
    value double,
    PRIMARY KEY (device_id, time)
)

存储库:

public interface DeviceDataRepository extends CassandraRepository<DeviceData> {

    @Query("SELECT * FROM device_data WHERE device_id = ?0 AND time > ?1")
    List<DeviceData> findByDeviceIdAndTime(UUID deviceId, Date from);
}

用法:

    Calendar calendar = new GregorianCalendar(1990, 1, 1);
    List<DeviceData> pump1Data = deviceDataService.findByDeviceIdAndFrom(UUID.fromString(pumpid), calendar.getTime());

这给了我以下错误:

Invalid INTEGER constant (633826800000) for "time" of type timeuuid; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Invalid INTEGER constant (633826800000) for "time" of type timeuuid

我究竟做错了什么?

4

1 回答 1

0

修复了问题:

@Query("SELECT * FROM device_data WHERE device_id = ?0 AND time > ?1")
List<DeviceData> findByDeviceIdAndTime(UUID deviceId, UUID from);

设备数据:

...
private UUID time;
...

控制器:

    List<DeviceData> pumpData = deviceDataService.findByDeviceIdAndFrom(UUID.fromString(id), calendar.getTime());
于 2017-11-29T14:14:45.037 回答