Squeryl 多对多:复合键(字段 1, 字段 2) 不存在



我正在学习Scala(2.11)和Play框架,我正在尝试使用Squeryl(0.9.5-7)实现人与技能之间的多对多关系。多人可以共享技能,一个人可以拥有许多技能。

Squeryl 文档告诉我这样做:

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

另外,我在文档中找不到复合键(fieldId,fieldId)。我不知道它起源于哪里。我希望有人能帮助我解决问题,或者至少解释我在哪里寻找解决方案。谢谢!

您可以在org.squery.dsl.QueryDsl内找到compositeKey

您需要确保导入扩展 QueryDsl org.squeryl.PrimitiveTypeMode._。这应该可以解决您收到的错误。

最新更新