【发布时间】:2013-03-02 14:37:32
【问题描述】:
使用 Slick,我试图将数据库表条目直接投影到它们所代表的案例类中。在example in the documentation 之后,我使用<> 运算符设置了映射投影:
case class SomeEntity3(id: Int, entity1: Int, entity2: Int)
val SomeEntityTable = new Table[SomeEntity3]("some_entity_table") {
def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
def entity1 = column[Int]("entity1")
def entity2 = column[Int]("entity2")
def * = id ~ entity1 ~ entity2 <> (SomeEntity3, SomeEntity3.unapply _)
}
现在,我想为 SomeEntity3 添加一些静态常量和辅助方法。为此,我创建了一个伴生对象。但是一旦我加入了这条线
object SomeEntity3
* 的定义弹出一个非常疯狂的多行错误,说一些关于“重载的方法值 带有替代项”的内容难以辨认。
伴生对象与 Slick 中的双向映射有何关系?我能否以某种方式实现我的目标?
【问题讨论】: