Question

My model is:

import scala.slick.driver.PostgresDriver.simple._
import scala.slick.lifted.TableQuery


class User(tag: Tag) extends Table[(Int, String, String)](tag, "User") {
def id = column[Int]("SUP_ID", O.PrimaryKey)
def name = column[String]("SUP_NAME")
def street = column[String]("STREET")
def * = (id, name, street)
}

//val users = TableQuery[Users]
val users=TableQuery[User]

I do this follow the example on

http://slick.typesafe.com/doc/2.0.1-RC1/gettingstarted.html#slick-examples

when I compile the error is:

[myslickclick] $ compile
[info] Compiling 9 Scala sources and 1 Java source to C:\assigment\myslickclick\
target\scala-2.10\classes...
[error] C:\assigment\myslickclick\app\model\User.scala:15: expected class or obj
ect definition
[error] val Users=TableQuery[User]
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 0 s, completed 03/03/2014 3:55:49 PM

I use slick 2.0.1 rc1. I think it is same, but there is still can not recognize the class.

Pas de solution correcte

Autres conseils

That's because you cannot declare values outside of classes or objects.

Your val users=TableQuery[User] should be in an object, like a UserDAO:

object UserDAO {
  val users = TableQuery[User]

  def all: ...

  def byId: ...
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top