Domanda

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top