Spring-boot-data-cassandra
CQL:
CREATE TABLE device_data (
device_id uuid,
time timeuuid,
unit text,
value double,
PRIMARY KEY (device_id, time)
)
Repository:
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);
}
Usage:
Calendar calendar = new GregorianCalendar(1990, 1, 1);
List<DeviceData> pump1Data = deviceDataService.findByDeviceIdAndFrom(UUID.fromString(pumpid), calendar.getTime());
This gives me the following error:
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
What am I doing wrong?
Fixed the issue:
@Query("SELECT * FROM device_data WHERE device_id = ?0 AND time > ?1")
List<DeviceData> findByDeviceIdAndTime(UUID deviceId, UUID from);
DeviceData:
...
private UUID time;
...
Controller:
List<DeviceData> pumpData = deviceDataService.findByDeviceIdAndFrom(UUID.fromString(id), calendar.getTime());