Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 找不到请求操作的编解码器:[timestamp<;->;java.lang.Long]_Scala_Cassandra - Fatal编程技术网

Scala 找不到请求操作的编解码器:[timestamp<;->;java.lang.Long]

Scala 找不到请求操作的编解码器:[timestamp<;->;java.lang.Long],scala,cassandra,Scala,Cassandra,我用scala编写了这个简单的程序来查询cassandra val session = cass.session lazy val stmt = cass.session.prepare( """ |select token(id), id, date, rId, tt | from foo | where token(id) > ? | and token(id) <= ?; """.stripMargin ) lazy val

我用scala编写了这个简单的程序来查询cassandra

val session = cass.session
lazy val stmt = cass.session.prepare(
   """
     |select token(id), id, date, rId, tt
     | from foo
     | where token(id) > ?
     | and token(id) <= ?;
   """.stripMargin
)

lazy val statement = stmt.bind().setLong(0, start).setLong(1, end)

def fromRow(row: Row): Foo = {
   val token = row.getLong(0)
   val id = row.getLong(1)
   val date = row.getLong(2)
   val rId = row.getLong(3)
   val tt = row.getInt(4)
   Foo(id, date, rId, tt)
}
val session=cass.session
lazy val stmt=cass.session.prepare(
"""
|选择令牌(id)、id、日期、rId、tt
|来自富
|其中令牌(id)>?

|和令牌(id)在表FOO中,有一个时间戳类型列,但在插入查询中将Long值传递给该列。可能是您将日期列类型定义为时间戳。插入一个时间戳类型值“2012-12-07T10:00:00-0000”如下所示。

根据链接,将
Date
类型的变量绑定到您的语句:

stmt.bind(new Date(start), new Date(end))

对于驱动程序v4.0,
时间戳
映射到
java.time.Instant
,因此:
stmt.bind(Instant.ofepochssecond(start),Instant.ofepochssecond(end))

是的,我知道,但问题是没有关于版本的信息,现在可能有人来这里寻找他的问题的答案(就像今天早上的我)。感谢库巴·文塔(KUBA WENTA)!
stmt.bind(new Date(start), new Date(end))