Custom Slick Codegen 在 `${container} trait` 之外生成映射大小写 类?

Custom Slick Codegen generate mapped case classes outside the `${container} trait`?

Slick Codegen 能否在 ${container} trait 之外生成所有映射案例 classes ,这样他们就不会继承它的类型?也许完全在另一个文件中,即 Models.scala?

// SuppliersRowsDAA.scala
import persistence.Tables

object SuppliersRowsDAA {
  case class Save(sup: Tables.SuppliersRow)
}   

我得到这个编译错误:

[error] /app/src/main/scala/persistence/dal/SuppliersDAA.scala:5: type mismatch;
[error]  found   : persistence.Tables.SuppliersRow
[error]  required: SuppliersDAA.this.SuppliersRow
[error]     case Save(sup) ⇒ sender ! db.run(Suppliers += sup)

使用 Tables#SuppliersRow 导入给出同样的错误。

如果我在自动生成的 trait Tables 之外手动剪切和粘贴 SuppliersRow 案例 class,它就可以工作!

....

trait Tables {

....
}
case class SuppliersRow(id: Int, userId: Int, name: String)
//EOF

EntityType 的原始 docWithCode 附加到 super.packageCode():

import slick.codegen.SourceCodeGenerator
import slick.model.Model
import scala.collection.mutable

class CustomizedCodeGenerator(model: Model) extends SourceCodeGenerator(model) {
  val models = new mutable.MutableList[String]

  override def packageCode(profile: String, pkg: String, container: String, parentType: Option[String]): String = {
    super.packageCode(profile, pkg, container, parentType) + "\n" + outsideCode
  }

  def outsideCode = s"${indent(models.mkString("\n"))}"

  override def Table = new Table(_) {
    override def EntityType = new EntityTypeDef {
      override def docWithCode: String = {
        models += super.docWithCode.toString + "\n"
        ""
      }
    }
  }

}