开发者

how to do polymorphic relations in lift?

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 L开发者_开发知识库istC with LongKeyedMetaMapper[ListC] {


} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜