Я использую PlayFramework 2.1.1 в сочетании с Slick 1.0.1 и Play-Slick-Plugin 0.3.2.
Определение абстрактного класса, который заставляет мои модели реализовывать «forInsert»-Mapper, не удается, потому что я не могу указать правильный тип возвращаемого значения. Мое текущее определение приводит к ошибке компиляции ниже, но я просто не могу отследить эту проблему и указать правильный тип.
import play.api.db.slick.Config.driver.KeysInsertInvoker
abstract class Model[M]( val table: String ) extends Table[M]( table )
{
def id = column[Int]( "id", O.PrimaryKey, O.AutoInc )
def forInsert: KeysInsertInvoker[M, Int]
}
object Course extends Model[Course]( "course" )
{
...
def forInsert = name ~ room <> ( apply _, unapply _ ) returning id
}
[error] Course.scala:27: polymorphic expression cannot be instantiated to expected type;
[error] found : [RU]play.api.db.slick.Config.driver.KeysInsertInvoker[model.Course,RU]
[error] required: play.api.db.slick.Config.driver.KeysInsertInvoker[model.Course,Int]
[error] def forInsert = name ~ room <> ( apply _, unapply _ ) returning id
[error] ^
[error] one error found
[error] (sample/compile:compile) Compilation failed
[error] Total time: 3 s, completed 18.06.2013 03:38:24