我有一个包含不同类型帖子的数据库,所以我做了这个:
sealed trait PostBase[T <: PostBase[T]] extends LongKeyedMapper[T] with IdPK {
object owner extends LongKeyedForeignKey(this, User)
object posted extends MappedDateTime(this)
}
case class TextPost() extends PostBase[TextPost] {
// Hic sunt Dracones
}
case class PhotoPost() extends PostBase[PhotoPost] {
// Hic sunt Ponies
}
我想使用案例类,因此我可以对match
获得的值进行User.posts
,请参阅此处:
class User extends MegaProtoUser[User] with OneToMany[Long, User] {
def getSingleton = User
object posts extends MappedOneToMany(/* ??? */)
}
那么为了获得MappedOneToMany
类型的帖子,我必须将PostBase
作为参数添加什么?这种只能在单表继承的情况下才能工作,我是对的吗?