0

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)
      }
    }
  }
4

1 に答える 1

5

ここに公式ドキュメントを恥知らずにコピーして貼り付けます。

Slick には Scala 2.10 が必要です。(Scala 2.9の場合は、Slick の前身であるScalaQueryを使用してください)。

于 2013-03-30T18:37:50.713 に答える