Hi,
It happens in line 12 of the schema (I have added a commentary to mark
the line). It's really simple
what I want to achieve here. A user has exactly one role. Between role
and right there is a m:n relationship.
assertion failed: expected return type of CompositeKey on method id
in com.test.User
java.lang.AssertionError: assertion failed: expected return type of
CompositeKey on method id in com.test.User
at scala.Predef$.assert(Predef.scala:91)
at org.squeryl.internals.PosoMetaData.<init>(PosoMetaData.scala:134)
at org.squeryl.View.<init>(View.scala:58)
at org.squeryl.Table.<init>(Table.scala:27)
at org.squeryl.Schema$class.table(Schema.scala:338)
at com.test.UserAdministrationSchema$.table(Schema.scala:11)
at org.squeryl.Schema$class.table(Schema.scala:335)
at com.test.UserAdministrationSchema$.table(Schema.scala:11)
at com.test.UserAdministrationSchema$.<init>(Schema.scala:12)
at com.test.UserAdministrationSchema$.<clinit>(Schema.scala)
object UserAdministrationSchema extends Schema {
val user = table[User] // line 12
val userRoles = table[UserRole]
val userRights = table[UserRight]
val roleToRight = manyToManyRelation(userRoles,
userRights).via[Role_Right](
(role, right, role_right) => (role_right.rolename ===
role.id,
right.id === role_right.rightname))
}
case class User(@Column("username") username: String, password:
String, surname: String,
givenname: String, email: Option[String],
phonenumber: Option[String],
isEnabled: Boolean, rolename: String) extends
KeyedEntity[String] {
// @Column("username")
def id: String = username
lazy val role = userRoles.where(ur => ur.rolename ===
rolename).single
def this() = this("", "", "", "", Some(""), Some(""), false, "")
}
case class UserRole(rolename: String) extends KeyedEntity[String] {
@Column("rolename")
val id: String = rolename
lazy val rights = UserAdministrationSchema.roleToRight.left(this)
}
case class UserRight(rightname: String) extends KeyedEntity[String] {
@Column("rightname")
val id: String = rightname
lazy val roles = UserAdministrationSchema.roleToRight.right(this)
}
case class Role_Right(rolename: String, rightname: String)
extends KeyedEntity[CompositeKey2[String, String]] {
def id = compositeKey(rolename, rightname)
}
Christian