0
我不能找到解决这个问题:斯卡拉:通用方法
这个特点:
trait BasicRepository[Schema <: Table[Entity] with Identifiable[Entity], Entity]
而且这样的:
trait ProfilePartRepository[Schema <: Table[Entity] with ProfilePart[Entity], Entity]
这个对象:
object PhoneNumberRepository extends BasicRepository[PhoneNumbers, PhoneNumber] with ProfilePartRepository[PhoneNumbers, PhoneNumber] {
而这个方法:
def insertProfilePart[Schema <: Table[Entity] with Identifiable[Entity], Entity](repository: BasicRepository[Schema, Entity], entities: Seq[Entity]) : Seq[Future[Int]]
该方法不编译。但我认为你可以看到我想达到的目标。签名有什么样子?
编辑:其实我不关心方法中的“模式”,它只是一个有效的BasicRepository。
EDIT2:编译错误(调用方法时,与AgnosticDriver.api是slick.driver.JdbcDriver):
inferred type arguments [persistence.slickSchemas.PhoneNumbers,Product with Serializable] do not conform to method insertProfilePart's type parameter bounds [Schema <: persistence.AgnosticDriver.api.Table[Entity] with persistence.slickSchemas.Identifiable[Entity],Entity]
什么是编译错误? –
加入问题: 推断的类型参数[persistence.slickSchemas.PhoneNumbers,Product with Serializable]不符合方法insertProfilePart的类型参数bounds [Schema <:persistence.AgnosticDriver.api.Table [Entity] with persistence.slickSchemas.Identifiable [实体],实体] –
从目睹这个问题我不明白为什么它会给你带来困难。是否可以创建重现错误的代码的独立(可编译)版本?然后有人可以至少尝试一下,看看发生了什么。 – marios