Вопрос

Does mapper allows creation of composite key in Models ? If yes, kindly give an example.

Это было полезно?

Решение

This is one example:

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 
} 

Example taken from the Lift mailing list

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top