如何在lift的映射器中为模型创建Composite-key?

时间:2011-11-08 07:27:16

标签: scala lift mapper

mapper是否允许在模型中创建复合键?如果是,请举个例子。

1 个答案:

答案 0 :(得分:1)

这是一个例子:

class FooBar extends LongKeyedMapper[FooBar] { 
  def getSingleton = FooBar 
  def primaryKeyField = id 
  object id extends MappedLongIndex(this) 
  object foo extends MappedLongForeignKey(this, Foo) 
  object bar extends MappedLongForeignKey(this, Bar) 
} 

object FooBar extends FooBar with LogKeyedMetaMapper[FooBar] { 
  override def dbIndexes = Index(foo, bar) :: super.dbIndexes 
} 

取自Lift mailing list

的示例