With ManyToMany the join table is defined by you, manually as a regular mapper. 
You have to tell MappedManyToMany about it and its foreign keys.
I will try to find time to make the wiki entry more clear.
Also, if the scaladocs are lacking let me know how they could be improved.

-------------------------------------
Matyjas<maty...@gmail.com> wrote:


My entities are like Programmers and Projects. There is a many to many
relationship between Programmers and Projects, but the relationship
has an attribute for type. Examples of relationship types are
Develops, Manages, Maintains, Tests, etc. In a traditional relational
db there would be a join table containing the type of relationship as
well as foreign keys to both Programmer and Project. I would like to
run queries such as "what projects does this programmer develop?"
which loosely translates to the following SQL:

SELECT * FROM projects WHERE programmer.id ==
programmer_project.programmer_id && programmer_project.project_id ==
project.id && programmer_project.type == "Develops" && programmer.id
== thisProgrammerId;

So far, I gave up on the ManyToMany Mapper because I could not figure
out how to add an attribute to the join table. The join table seemed
to be hidden away.

What I have now is both Programmer and Project extending OneToMany,
where the many side is a ProgrammerProject class. Something like:

...
class Programmer extends LongKeyedMapper[Programmer] with
OneToMany[Long, Programmer] {
...
        object programmerProjects extends MappedOneToMany(ProgrammerProject,
ProgrammerProject.programmer) with Owned[ProgrammerProject] with
Cascade[ProgrammerProject]
...
}

...
class Project extends LongKeyedMapper[Project] with OneToMany[Long,
Project] {
...
        object programmerProjects extends MappedOneToMany(ProgrammerProject,
ProgrammerProject.project) with Owned[ProgrammerProject] with
Cascade[ProgrammerProject]
...
}

object RelationshipType extends Enumeration {
        val Develops = new Val(1, "Develops")
        val Manages = new Val(2, "Manages")
}
...
class ProgrammerProject extends LongKeyedMapper[ProgrammerProject] {
...
        object relationshipType extends MappedEnum(this, RelationshipType)

        object programmer extends LongMappedMapper(this, Programmmer)

        object project extends LongMappedMapper(this, Project)
}


This arrangement isnt terrific, but it would be okay if I could
construct valid QueryParams. I would expect something like the
following to work:

Project.findAll(In(Project.id, ProgrammerProject.project,
                          In(ProgrammerProject.programmer,
Programmer.id,
                             By(ProgrammerProject.relationshipType,
RelationshipType.Develops))))

But it doesnt. Any advice would be most appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to