我正在試圖從光滑表中得到一個結果組。在Slick中進行分組
Sql : Select * from Jobs GROUP BY category ;
類
case class JobEntity(id:Option[Long],category:String,properties:String)
我華而不實的功能
def getJobsByCategory() :(String,Future[Seq[JobsEntity]]) =
db.run(jobs.groupBy(_.category).map{ case(category,res) =>
(category,res)}.result)
錯誤:
No matching Shape found.
[ERROR] Slick does not know how to map the given types.
[ERROR] Possible causes: T in Table[T] does not match your * projection,
[ERROR] you use an unsupported type in a Query (e.g. scala List),
[ERROR] or you forgot to import a driver api into scope.
[ERROR] Required level: slick.lifted.FlatShapeLevel
[ERROR] Source type: (slick.lifted.Rep[String], slick.sql.FixedSqlStreamingAction[Seq[org.exadatum.xstream.persistence.models.SparkConfigEntity],org.exadatum.xstream.persistence.models.SparkConfigEntity,slick.dbio.Effect.Read])
[ERROR] Unpacked type: T
[ERROR] Packed type: G
[ERROR]
有可能是一些問題與返回類型,但我不知道是什麼 爲該IDE產生誤差
Expression of type Future[Seq[Nothing]] doesn't conform to expected type (String,Future[Seq[JobsEntity]])
你能發表你的表格定義嗎?很可能你的*定義不符合你的案例類格式(字段和類型的數量) –