lift中如何做多态关系?
我是 Lift 和 scala 的新手,正在尝试做一些事情。 目前我想与 lift 创建多态关联 映射器。
这里有一个例子:
我想创建一个类 Entry ,它可以是 n 中任何一个的条目 ListX 对象。我怎样才能让父母和条目成为 多态性? 是否有一种通用的方法来处理这些多态关联 一对多和双向多对多?
class Entry extends BaseModel[Entry] {
def getSingleton = Entry
object parent extends MappedBase(this, AnyList)
}
object Entry extends Entry with LongKeyedMetaMapper[Entry] {
}
class ListA extends BaseModel[ListA] with OneToMany[Long, ListA] {
def getSingleton = ListA
object entries extends MappedOneToMany(Entry, Entry.parent)
}
object ListA extends ListA with LongKeyedMetaMapper[ListA] {
}
class ListB extends BaseModel[ListB] with OneToMany[Long, ListB] {
def getSingleton = ListB
object entries extends MappedOneToMany(Entry, Entry.parent)
}
object ListB extends ListB with LongKeyedMetaMapper[ListB] {
}
class ListC extends BaseModel[ListC] with OneToMany[Long, ListC] {
def getSingleton = ListC
object entries extends MappedOneToMany(Entry, Entry.parent)
}
object ListC extends ListC with LongKeyedMetaMapper[ListC] {
}
I am new to Lift and scala and trying to do some stuff.
in the moment i want to create polymorphic associations with the lift
mapper.
here one example:
i want to create a class Entry what can be an entry in any of the n
ListX objects. How can i accomplish to let parent and entries be
polymorphic?
Is there a generic Way to to these polymorphic associations with
OneToMany & ManyToMany in both directions?
class Entry extends BaseModel[Entry] {
def getSingleton = Entry
object parent extends MappedBase(this, AnyList)
}
object Entry extends Entry with LongKeyedMetaMapper[Entry] {
}
class ListA extends BaseModel[ListA] with OneToMany[Long, ListA] {
def getSingleton = ListA
object entries extends MappedOneToMany(Entry, Entry.parent)
}
object ListA extends ListA with LongKeyedMetaMapper[ListA] {
}
class ListB extends BaseModel[ListB] with OneToMany[Long, ListB] {
def getSingleton = ListB
object entries extends MappedOneToMany(Entry, Entry.parent)
}
object ListB extends ListB with LongKeyedMetaMapper[ListB] {
}
class ListC extends BaseModel[ListC] with OneToMany[Long, ListC] {
def getSingleton = ListC
object entries extends MappedOneToMany(Entry, Entry.parent)
}
object ListC extends ListC with LongKeyedMetaMapper[ListC] {
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论