Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've looked this up. It looks as though the joins are done in the object layer. </p> <p>Extrapolated from <a href="http://exploring.liftweb.net/master/index-8.html" rel="nofollow">http://exploring.liftweb.net/master/index-8.html</a> to your case: </p> <pre><code>// Accessing foreign objects class Employee extends LongKeyedMapper[Employee] with IdPK { ... object department extends MappedLongForeignKey(this, Department) def departmentName = Text("My department is " + (department.obj.map(_.name.is) openOr "Unknown")) } class Department ... { ... def entries = Employee.findAll(By(Employee.department, this.id)) } </code></pre> <p>If you want to do many-to-many mappings you’ll need to provide your own<br> “join” class with foreign keys to both of your mapped entities. </p> <pre><code>// DepartmentId Entity class DepartmentId extends LongKeyedMapper[DepartmentId] with IdPK { def getSingleton = DepartmentId object name extends MappedString(this,100) } object DepartmentId extends DepartmentId with LongKeyedMetaMapper[DepartmentId] { override def fieldOrder = List(name) } </code></pre> <p>Next, we define our join entity, as shown below.<br> It’s a LongKeyedMapper just like the rest of the entities,<br> but it only contains foreign key fields to the other entities. </p> <pre><code>// Join Entity class DepartmentIdTag extends LongKeyedMapper[DepartmentIdTag] with IdPK { def getSingleton = DepartmentIdTag object departmentid extends MappedLongForeignKey(this,DepartmentId) object Employee extends MappedLongForeignKey(this,Employee) } object DepartmentIdTag extends DepartmentIdTag with LongKeyedMetaMapper[DepartmentIdTag] { def join (departmentid : DepartmentId, tx : Employee) = this.create.departmentid(departmentid).Employee(tx).save } </code></pre> <p>To use the join entity, you’ll need to create a new instance and set the<br> appropriate foreign keys to point to the associated instances. As you can see,<br> we’ve defined a convenience method on our Expense meta object to do just that.<br> To make the many-to-many accessible as a field on our entities, we can use the<br> HasManyThrough trait, as shown below </p> <pre><code>// HasManyThrough for Many-to-Many Relationships class Employee ... { object departmentids extends HasManyThrough(this, DepartmentId, DepartmentIdTag, DepartmentIdTag.departmentid, DepartmentIdTag.Employee) } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload