I am trying to write a simple BaseDao class using the excellent ORF framework.
However, I ran into a problem when using generic typed keys. I get a compilation error when I try to use the '===' operator in my common BaseDao class. Compilation error: value === is not a member of a parameter of type TKey
My dao class with its hard method is defined as:
import org.squeryl.PrimitiveTypeMode._
import org.squeryl._
abstract class BaseDao[TKey, T <: BaseEntity[TKey]](val table: Table[T]) {
def delete(entity: T) : Boolean = {
table.deleteWhere(record => record.id === entity.id) //This is where I get the compile error
}
}
BaseEntity is defined as:
abstract class BaseEntity[TKey] extends KeyedEntity[TKey]
I import PrimitiveTypeMode into my Dao class too ... My first was that TKey needed to be limited to what the === operator was attached to, but looking at the source, there are no explicit restrictions around the operator, so I'm a little lost .
squeryl : https://github.com/max-l/Squeryl/blob/master/src/main/scala/org/squeryl/dsl/TypedExpression.scala