2017-04-04 63 views
0

我有类似this油滑:TableQuery [SOMETYPE]。结果没有发现

一个问题,但我使用阶2.11.1,光滑3.2.0,并与SBT手动编译,未使用的IntelliJ。

我定义了数据库的dntity:

案例类ScheduleItem(ID:选项[INT],cron的:字符串,脚本:字符串,created_at:龙的updated_at:龙,CREATED_BY:字符串,updated_by:字符串)

object ScheduleItems { 

    class ScheduleItemsT(tag: Tag) extends Table[ScheduleItem](tag, "schedule_items") { 

    def id = column[Int]("id", O.PrimaryKey, O.AutoInc) 

    def cron = column[String]("column") 

    def script = column[String]("script") 

    def created_at = column[Long]("created_at", SqlType("timestamp without time zone")) 

    def updated_at = column[Long]("updated_at", SqlType("timestamp without time zone")) 

    def created_by = column[String]("created_by") 

    def updated_by = column[String]("updated_by") 

    def * = (id.?, cron, script, created_at, updated_at, created_by, updated_by) <> (ScheduleItem.tupled, ScheduleItem.unapply) 
    } 

    val table = TableQuery[ScheduleItemsT] 
} 

我尝试运行一个简单的查询,以获得databsae的所有元素:

db.run(ScheduleItems.table.result) 

编译时,这是SBT输出:

[info] Loading project definition from /home/claudino/Projetos/Testes/Agendador2_0/project 
[info] Set current project to Agendador2_0 (in build file:/home/claudino/Projetos/Testes/Agendador2_0/) 
[info] Compiling 3 Scala sources to /home/claudino/Projetos/Testes/Agendador2_0/target/scala-2.11/classes... 
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling... 
[info] Compilation completed in 10.646 s 
[error] /home/claudino/Projetos/Testes/Agendador2_0/src/main/scala/com/webradar/qns/Main.scala:13: value result is not a member of slick.lifted.TableQuery[com.webradar.Main.schedule.model.ScheduleItems.ScheduleItemsT] 
[error]  db.run(ScheduleItems.table.result) 
[error]        ^
[error] one error found 
[error] (compile:compileIncremental) Compilation failed 
[error] Total time: 13 s, completed 04/04/2017 11:42:20 

也就是说,与slick 3.20文档不同,结果不是TableQuery [SomeType]的成员。任何想法?

+0

,如果你需要一个完整的工作示例,我建这个小例子,较早前:https://github.com/pedrorijo91/play-slick3-steps。还有一篇博客文章可能会变得方便:http://pedrorijo.com/blog/play-slick/ – pedrorijo91

回答

1

我想你只是忘了导入光滑的配置文件api。你的情况:

import slick.jdbc.PostgresProfile.api._ 
+0

谢谢,我已经导入另一个文件,我定义了数据库连接。该文件正在导入,但看起来不够。谢谢。 –