1

我在数据库中有两个类,并希望建立一对多的关系。没什么复杂的。但是,我在 squeryl 的 _splitEquality 中遇到断言失败(第 576 行)。Squeryl 是 0.9.5 版

所以我有一个模式

object Tables extends Schema {
val foo = table[Foo]("foo_table")
val bar = table[Bar]("bar_table")

val fooBar = oneToManyRelation(foo,bar).via((f,b) => f.id === bar.foo_fk)
}

foo 在哪里

 class Foo (val foo_id: String, val useful_info: String) 
   extends KeyedEntity[String] {
 override def id: String = foo_id
 }

酒吧是

class bar (val foo_fk) {
def useful_info = Tables.fooBar.right(this).head.useful_info
}

但是,这在运行时会因前面提到的断言失败而失败,特别是: assert(ee.right._fieldMetaData.isIdFieldOfKeyedEntity) 失败

4

1 回答 1

1

I fixed it by using a column annotation on Foo instead of overriding id. So foo became

class Foo (
@Column("foo_id")
val id: String, 
val useful_info: String) 
  extends KeyedEntity[String] {
}

I'm not totally sure why this worked, but I'm annoyed that it did.

于 2012-05-10T11:33:24.337 回答