Slick中的编译查询

时间:2014-12-01 18:11:46

标签: postgresql scala playframework compiled play-slick

我需要在Slick中使用Play和PostgreSQL编译一个查询

val bioMaterialTypes: TableQuery[Tables.BioMaterialType] = Tables.BioMaterialType

def getAllBmts() = for{ bmt <- bioMaterialTypes } yield bmt

val queryCompiled = Compiled(getAllBmts _)

但在Scala IDE中,我在Apply of Compiled

中收到此错误
Multiple markers at this line
- Computation of type () => scala.slick.lifted.Query[models.Tables.BioMaterialType,models.Tables.BioMaterialTypeRow,Seq] 
 cannot be compiled (as type C)
- not enough arguments for method apply: (implicit compilable: scala.slick.lifted.Compilable[() => 
 scala.slick.lifted.Query[models.Tables.BioMaterialType,models.Tables.BioMaterialTypeRow,Seq],C], implicit driver: 
 scala.slick.profile.BasicProfile)C in object Compiled. Unspecified value parameters compilable, driver.

这是我的进口商品:

import scala.concurrent.Future
import scala.slick.jdbc.StaticQuery.staticQueryToInvoker
import scala.slick.lifted.Compiled
import scala.slick.driver.PostgresDriver
import javax.inject.Inject
import javax.inject.Singleton
import models.BioMaterialType
import models.Tables
import play.api.Application
import play.api.db.slick.Config.driver.simple.TableQuery
import play.api.db.slick.Config.driver.simple.columnExtensionMethods
import play.api.db.slick.Config.driver.simple.longColumnType
import play.api.db.slick.Config.driver.simple.queryToAppliedQueryInvoker
import play.api.db.slick.Config.driver.simple.queryToInsertInvoker
import play.api.db.slick.Config.driver.simple.stringColumnExtensionMethods
import play.api.db.slick.Config.driver.simple.stringColumnType
import play.api.db.slick.Config.driver.simple.valueToConstColumn
import play.api.db.slick.DB
import play.api.db.slick.DBAction

1 个答案:

答案 0 :(得分:-1)

你可以简单地做

val queryCompiled = Compiled(bioMaterialTypes)