DISABLE ADBLOCK

ADBlock is blocking some content on the site

ADBlock errore
Results found: 

Question

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

Solution

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

If you like, leave us your opinion

Was the article helpful and is it translated correctly?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow