O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating one-to-many relationships

After learning how to map a database table to a Scala class using Record, we will learn how to take the next step, which is mapping a one-to-many relationship using Record.

Getting ready

We are going to modify the project from the last recipe. You can duplicate the project or modify it; it is your choice.

  1. Create a table called phones:
    create table phones (
      id serial primary key,
      number varchar(15),
      contact bigint
    )
  2. Add the following import statements in the Boot.scala file:
    import net.liftweb.http.S
    import net.liftweb.util.LoanWrapper
    import net.liftweb.squerylrecord.RecordTypeMode._
  3. Add the following code into the boot method in the Boot.scala file:
    S.addAround(new LoanWrapper { override def apply[T](f: => T): T = inTransaction(f) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required