使用最新版本的phantom(2.42.0)和scala(2.12.0-rc2),查询数据库时找不到参数ev:nothing的隐式表达式

olhwl3o2  于 2021-06-14  发布在  Cassandra
关注(0)|答案(0)|浏览(207)

我正在升级到phantom dsl 2.42.0和scala 2.12的最新版本,根据迁移指南,现在我不需要生成fromrow()方法,但是在查询数据库时,我没有找到任何隐式参数(编译时)。
我试着用fromrow方法写,但还是不管用
我的案例课是-

case class Ball(matchId: Int,
                      inningsid: Int,
                      ballNbr: Int,
                      timeScore: Long,
                      batStrikerDots: Option[Int],
                      batStrikerFours: Option[Int],
                      commFormats: Map[String, CommentaryFormats],
                      .......
                      ......)

class Ball extends Table[BallData, Ball] with CassandraSession with CommentaryPrimitive {

object matchId extends IntColumn with PartitionKey {
    override lazy val name = col_name
  }

  object inningsId extends IntColumn with PrimaryKey with ClusteringOrder with Descending {
    override lazy val name = col_name
  }

  object ballNbr extends IntColumn with PrimaryKey with ClusteringOrder with Descending {
    override lazy val name = col_name
  }

  object timeScore extends DateTimeColumn with PrimaryKey with ClusteringOrder with Descending {
    override lazy val name = col_name
  }

object commentaryFormat extends MapColumn[String, CommentaryFormats] {
    override lazy val name = "comm_format"
  }

............
............

}

列名称是各自的列名。
其中comm\ u format是udt,因此我为它定义了commentaryprimitive,它注册了一个编解码器,说明如何将cassandra数据反序列化到scala case类,cassandarasession提供隐式键空间和会话。
这是我注册编解码器的原始代码-

override def cassandraType: String = {

            val format_types = CassandraConnector.getSession.getCluster.getMetadata.getKeyspace("matches_data").getUserType("format_types")
            val formatCodecCodec = new CommentaryCodec(TypeCodec.userType(format_types), classOf[CommentaryFormats])

        CassandraConnector.registerCodec(formatCodecCodec)

            format_types.toString()
        }

override def asCql(value: PrimitiveType): String = ???

        override def dataType: String = ???

        override def serialize(obj: PrimitiveType, protocol: ProtocolVersion): ByteBuffer = ???

        override def deserialize(source: ByteBuffer, protocol: ProtocolVersion): PrimitiveType = ???

但我无法解决这个问题-
select.where(.matchid eqs matchid)(…).one()(…)-->检索球对象
... -> 找不到隐式
使用新版本的幻影dsl,它应该自动解析球数据,但它抛出的错误没有发现。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题