【问题标题】:Does TypeSafe Slick work on Scala 2.9.3?TypeSafe Slick 是否适用于 Scala 2.9.3?
【发布时间】:2013-03-21 06:17:59
【问题描述】:

TypeSafe Slick 能否在 Scala 2.9.3 上运行?我明白了

[ERROR] exception when typing query.list
exception when typing query.listscala.tools.nsc.symtab.Types$TypeError: class file needed by StatementInvoker is missing.
[INFO] class file needed by StatementInvoker is missing.
[INFO] reference type Either of object package refers to nonexisting symbol.

当我使用 Scala 2.10.x 时,这种情况就消失了,但我对 Scala 太陌生了,无法理解为什么。

import slick.session.Database
import scala.slick.jdbc.StaticQuery
import Database.threadLocalSession
import com.typesafe.config.ConfigFactory

object PostgresDao {

  protected val conf = ConfigFactory.load

  def findFoo(a: Int, b: String): Option[Int] = {

    Database.forURL("jdbc:postgresql://localhost/bar", driver = "org.postgresql.Driver") withSession {

      val query = StaticQuery.query[(Int, String), Int](
        """
        select some_int
        from some_table t
        where t.a = ? and t.b = ?
        """.stripMargin)

      val list: List[Int] = query.list((a, b))

      if (list.isEmpty) {
        None
      }
      else {
        Some(list.head)
      }
    }
  }

【问题讨论】:

    标签: scala slick


    【解决方案1】:

    我在这里无耻地抄袭官方文档:

    Slick requires Scala 2.10.(对于 Scala 2.9,请使用 ScalaQuery, Slick 的前身)。

    【讨论】:

    • 我可耻地错过了这一点。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-11
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多