1

I have two classes in a database, and wish to set up a one to many relation. Nothing complicated. However, I'm getting an assertion failure in squeryl's _splitEquality (on line 576). Squeryl is version 0.9.5

So I have a schema

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)
}

Where foo is

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

and bar is

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

However, this fails at runtime with the previously mentioned assertion failure, specifically that: assert(ee.right._fieldMetaData.isIdFieldOfKeyedEntity) fails

Squidly
  • 2,707
  • 19
  • 43

1 Answers1

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.

Squidly
  • 2,707
  • 19
  • 43
  • The issue here was that KeyedEntity MUST use the name "id" for the primary key field. In the first example the "def" was not enough to work around this limitation. In the 2nd one you abode by that rule and things worked. – jsalvata Sep 30 '12 at 22:10