0
下面是我的代碼油滑不知道如何映射給定類型
package com.codemobile.box.modules.groups.repo.sql
import com.codemobile.box.core.services.DatabaseService
import com.codemobile.box.modules.groups.model.GroupEntity
trait GroupEntityTable {
protected val databaseService: DatabaseService
import databaseService.driver.api._
class Groups(tag: Tag) extends Table[GroupEntity](tag, "groups"){
val id = column[Int]("grp_id",O.PrimaryKey,O.AutoInc)
val name = column[String]("grp_name")
val permissions = column[String]("grp_permissions")
def * = (id, name, permissions) <> (GroupEntity.tupled, GroupEntity.unapply)
}
protected val groupsTableQuery = TableQuery[Groups]
}
package com.codemobile.box.modules.groups.model
case class GroupEntity(id: Option[Int] = None, name: String, permissions : Option[String] = None)
然而,當我運行激活來看,我得到異常
[error] Slick does not know how to map the given types.
[error] Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
[error] Required level: slick.lifted.FlatShapeLevel
[error] Source type: (slick.lifted.Rep[String], slick.lifted.Rep[String], slick.lifted.Rep[Option[Int]])
[error] Unpacked type: (Option[Int], String, Option[String])
[error] Packed type: Any
[error] def * = (name, permissions, id.?) <> (GroupEntity.tupled, GroupEntity.unapply)
[error] ^
[error] one error found
錯誤後添加
?
不匹配的代碼。 – pedrofurla