My guess was right, it's simply null because there is no sample
created for CompositeKeys.
I have added new code accordingly to FieldMetaData.scala, more
precisely to the _defaultValueFactory.
The sample is simply a >> new CompositeKey2("", "") <<. Now the
NullPointerException is gone.
However, it still does not work.
Given the following relation:
val uniquePersonToAddress = {
val rel = oneToManyRelation(uniquePeople, uniquesAddresses)
rel.via((person, address) =>
person.id === address.personId)
}
Where
person.id is
def id = compositeKey(firstName, lastName)
and address.personId is
val personId: CompositeKey2[String, String]
Now I have added some printf stuff to FieldReferenceLinker.scala:
https://gist.github.com/796382
When I run my test and Squeryl tries to create the relation from above
I get the following output:
set members to empty ArrayBuffer
members before: None
members afterwards: Some(ArrayBuffer('SelectElementReference:cannot
evaluate:java.lang.String, 'SelectElementReference:cannot
evaluate:java.lang.String))
set members to empty ArrayBuffer
members before: None
members afterwards: Some(ArrayBuffer())
Can someone explain that to me?
As it seems (to me at the moment) the members get magically filled
with two SelectElementReferences.
Although only those of
person.id, not those of address.personId,
which is the problem in the end, since the Equality cannot be built
like that:
private [squeryl] def buildEquality(ck: CompositeKey):
EqualityExpression = {
val it1 = members.toList
val it2 = ck.members.toList
EqualityExpression(it1 zip it2)
}
I mean the _compositeKeyMembers is an empty ArrayBuffer in both cases
apparently,
how can it be mapped to two SelectElementReferences in one case?
Real debugging would maybe help in this case,
but I haven't managed to set up my IDE for this.
Although there is some kind of cli debugging possible with Scala 2.8.
I will try that next.