How does HasManyThrough differ from MappedManyToMany?
Most of the lift-mapper documentation on many-to-many relationships documents the use of MappedManyToMany for mapping the relationship. But in 开发者_Python百科in Exploring Lift, I see that the authors use HasManyThrough instead.
What's the difference between the two? Is one preferred over the other?
HasManyThrough
- only gives you read support
- you will have to call
get
on it to get the elements - you need to create the join table entries manually
MappedManyToMany
- also handles writes
- can be used like a collection (for example add and remove objects with
+=
and-=
) - join table entries will be created automatically
At least these are the differences I noticed when moving from HasManyThrough
to MappedManyToMany
in my project.
So I think MappedManyToMany
is a new version and is the preferred one, while HasManyThrough
is propably kept for compatibility reasons.
精彩评论