Squeryl 多对多:compositeKey(field1, field2) 不存在
Squeryl Many to Many: compositeKey(field1, field2) doesn't exist
我正在学习 Scala (2.11) 和 Play Framework,我正在尝试使用 Squeryl (0.9.5-7) 实现人与技能之间的多对多关系。多人可以共享技能,一个人可以拥有多个技能。
Squeryl docs 告诉我这样做:
class PersonToSkill(val personId: Long, val skillId: Long) extends KeyedEntity[CompositeKey2[Long,Long]] {
def id = compositeKey(personId, skillId)
}
但是编译器告诉我这个:
not found: value compositeKey
[error] def id = compositeKey(personId, skillId)
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
此外,我在文档中找不到 compositeKey(fieldId, fieldId)。我不知道它来自哪里..
我希望有人可以帮助我解决我的问题,或者至少向我解释在哪里寻找解决方案。谢谢!
中找到 compositeKey
您需要确保导入扩展 QueryDsl 的 org.squeryl.PrimitiveTypeMode._
。这应该可以解决您收到的错误。
我正在学习 Scala (2.11) 和 Play Framework,我正在尝试使用 Squeryl (0.9.5-7) 实现人与技能之间的多对多关系。多人可以共享技能,一个人可以拥有多个技能。
Squeryl docs 告诉我这样做:
class PersonToSkill(val personId: Long, val skillId: Long) extends KeyedEntity[CompositeKey2[Long,Long]] {
def id = compositeKey(personId, skillId)
}
但是编译器告诉我这个:
not found: value compositeKey
[error] def id = compositeKey(personId, skillId)
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
此外,我在文档中找不到 compositeKey(fieldId, fieldId)。我不知道它来自哪里.. 我希望有人可以帮助我解决我的问题,或者至少向我解释在哪里寻找解决方案。谢谢!
compositeKey
您需要确保导入扩展 QueryDsl 的 org.squeryl.PrimitiveTypeMode._
。这应该可以解决您收到的错误。