1

I am trying to create a database with squeryl. This DB needs a Mapping between 2 unrelated Tables. My Problem is that one of the unrelated Tables has a CompositeKey2 as PrimaryKey.

When I try to create my Schema, it always throws an Exception. I've come accross a lot of Exceptions. Here are some Infos of what I am trying to do:

class Table1(val foo: Long,
             val bar: String
) extends KeyedEntity[CompositeKey2[Long, String]] {

    def id = compositeKey(foo, bar)
}

class Table2(val data: Array[Byte]) extends KeyedEntity[Long] {

    val id = 0L
} 

class Table1ToTable2Mapping(val table1Foo: Long,
                            val table1Bar: String,
                            val table2Id: Long
    ) extends KeyedEntity[CompositeKey3[Long, String, Long]] {

    def id = compositeKey(table1Foo, table1Bar, table2Id)
}

Every Schema declaration I've tried with its Exception:

//Schema:
oneToManyRelation(table1, table1ToTable2Mapping).via((t1, t1Tot2) => t1.id.a2 === t1Tot2.table1Bar)

Caused by: java.lang.ClassCastException:
org.squeryl.PrimitiveTypeMode$$anon$1 cannot be cast to
org.squeryl.dsl.ast.SelectElementReference

//Schema:
oneToManyRelation(table1, table1ToTable2Mapping).via((t1, t1Tot2) => t1.bar === t1Tot2.table1Bar)

java.lang.AssertionError: assertion failed

Could this behaviour be related to THIS ticket?
Is there a known work around?

B. Kemmer
  • 1,517
  • 1
  • 14
  • 32

0 Answers0