Working with link tables in Lift Mapper

Showing 1-2 of 2 messages
Working with link tables in Lift Mapper Jacobus 10/12/12 3:58 AM
Good day,

Apologies for asking this question again, but I really need to know how to do this. I asked this question earlier, but it turned into a discussion for if this was good design or not, which is not what I am after at this point.

From the Lift-Web Mapper model below, how do I access the fields under AssignmentformLink?

    object TForm extends TForm with LongKeyedMetaMapper[TForm]
   
    class TForm extends LongKeyedMapper[TForm] with IdPK with ManyToMany {
      def getSingleton = TForm
   
      object label extends MappedString(this, 40)
   
      object pattern extends MappedString(this, 200)
   
      object assignments extends MappedManyToMany(
          AssignmentformLink, AssignmentformLink.assignment, AssignmentformLink.form, TForm)
   
    }
   
    object AssignmentformLink extends AssignmentformLink with LongKeyedMetaMapper[
AssignmentformLink] {
      override def dbIndexes = Index(form, assignment) :: super.dbIndexes
    }
   
    class AssignmentformLink extends LongKeyedMapper[AssignmentformLink] with IdPK {
      def getSingleton = AssignmentformLink
   
      object form extends MappedLongForeignKey(this, TForm)
   
      object assignment extends MappedLongForeignKey(this, Assignment)
   
      object order extends MappedInt(this)
   
      object readonly extends MappedBoolean(this)
   
      object required extends MappedBoolean(this)
   
      object visible extends MappedBoolean(this)
   
    }
   
    object Assignment extends Assignment with LongKeyedMetaMapper[Assignment]
   
    class Assignment extends LongKeyedMapper[Assignment] with IdPK with ManyToMany {
      def getSingleton = Assignment
   
      object id_parent extends MappedLong(this)
   
      object label extends MappedString(this, 40)
   
      object order extends MappedInt(this)
   
      object guard extends MappedString(this, 200)
   
      object forms extends MappedManyToMany(
          AssignmentformLink, AssignmentformLink.assignment, AssignmentformLink.form, TForm)
   
    }

To get an assignmet and the forms linked to it, you do this:

    val assignments = Assignments.find(By(Assignment.id, 123))
  
    assignments match {
      case Full(as) => {
        val forms = as.forms
    .....

But I have no idea how to navigate to the `order, readonly, required...` fields under `AssignmentformLink`.

I realise I can search for the link manually, ie. `AssignmentformLink.find(By(form...),By(assignment...))`, but this will result in inefficient code and really misses the point of using objects.

I need to be able to *navigate* from the form to the link table's fields.

Kind regards,
Jacobus

This message has been hidden because it was flagged for abuse.