0
我得到以下錯誤,我不明白什麼是錯的。圓滑的通用創建錯誤
could not find implicit value for parameter tm: scala.slick.ast.TypedType[I]
[error] def id = column[I]("id",O.PrimaryKey)
[error] ^
此錯誤指的是FkTable。我列出了代碼,以及顯示我的意圖的評論。我的計劃是爲桌子打好基礎,然後讓我的CRUD服務關閉。
//ROWS
trait Row[I<:AnyVal,M[_]]{
val id:M[I]
}
//TABLES
/**
* @tparam I This is the type of the ID column in the table
* @tparam M The row may contain a wrapper (such as Option) which communicates extra information to Slick for the row
* data. M can be Id, which means that M[I] == Id[I] == I which means the Row item can contain a simple type.
* @tparam R The class that represents a row of data. As explained above, it is described by its __id__ which is of
* type M[I].
*/
abstract class BasicTable[I <:AnyVal,M[_], R <:Row[I,M]](tag: Tag, name: String) extends Table[R](tag, name) {
def id: Column[I]
}
/**
* @note The BasicTable takes Long,Option because longs can be incremented, and in slick this is communicated by an
* Option value of None. The None is read and tells Slick to generate the next id value. This implies that the
* Row (R) must have a value __id__ that is an Option[Long], while the id column must remain Long.
*/
abstract class IncrTable[R <: Row[Long,Option]](tag: Tag, name: String) extends BasicTable[Long,Option,R](tag, name){
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
}
/**
*
* @param refTable
* @tparam I This is the type of the ID column in the table
* @tparam R The class that represents a row of data. As explained above, it is described by its __id__ which is of
* type M[I].
* @tparam M2 The Wrapper for the referenced table's id value
* @tparam R2 The class that represents the referenced table's row of data
*/
abstract class FkTable[I<: AnyVal,R<:Row[I,Id],M2[_], R2 <:Row[I,M2]](tag: Tag, name: String,refTable:TableQuery[BasicTable[I,M2,R2]]) extends BasicTable[I,Id,R](tag, name){
def id = column[I]("id", O.PrimaryKey)
//Foreign Key
def fkPkconstraint = foreignKey("PK_FK", id, refTable)(_.id)
}
我不得不爲BaseTypedType [I]添加隱式以使工作ColumnExtensionMethods方法與I字段。 (光滑的3.2.1) – sunofkyuss