简体   繁体   English

如何编写/使用诸如rowToStringSequence Column [Seq [String]]之类的主动脉提取器

[英]How to write/use a anorm Extractor like rowToStringSequence Column[Seq[String]]

i wrote this row converter. 我写了这个行转换器。

implicit def rowToStringSequence: Column[Seq[String]] = Column.nonNull { (value, meta) =>
    val MetaDataItem(qualified, nullable, clazz) = meta
    value match {
      case data: Seq[String] => Right(data)
      case _ => Left(TypeDoesNotMatch(
        "Cannot convert " + value + ":" + value.asInstanceOf[AnyRef].getClass +
        " to String Array for column " + qualified))
    }
  }

Unfortunately, I do not know how to use it within a case class. 不幸的是,我不知道如何在案例类中使用它。 For instance: 例如:

case class profile ( eyeColor: Seq[String] )

The profile companion object: 配置文件随播对象:

object Profile{
  val profile= {
      get[Seq[String]]("eyeColor") map {
        case
        eyeColor => Profile(eyeColor)
      }
   }
}

The compilation error message is: could not find implicit value for parameter extractor: anorm.Column[Seq[String]] 编译错误消息是:找不到参数提取器的隐式值:anorm.Column [Seq [String]]

I need a hint. 我需要一个提示。

Thank you!! 谢谢!!

anorm.Column is made to convert JDBC data to desired Scala type. anorm.Column可以将JDBC数据转换为所需的Scala类型。 So first question is which kind of JDBC you want to convert as Seq[String] (not being by itself a JDBC type). 因此,第一个问题是要将哪种JDBC转换为Seq[String] (本身不是JDBC类型)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM