Juha,

Yep... Lift doesn't do a lot of automagic stuff with One to Many relations.
Maybe we'll look into doing more with this once we move to the Record/Field
code.

Thanks,

David

On Sun, Nov 23, 2008 at 1:47 PM, Juha L <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I'm trying to learn some Scala and Lift, and I'm currently playing
> with the Lift mapper. I have however stumbled upon a problem for which
> I don't seem to be able to find answer from the examples or by using
> Google. How do you create one-to-many mapping with lift mapper?
>
> I have something like
>
> class Parent extends KeyedMapper[Long, Parent] {
>  def getSingleton = Parent
>  def primaryKeyField = id
>
>  object id extends MappedLongIndex(this)
> }
>
> class Child extends KeyedMapper[Long, Child] {
>  def getSingleton = Child
>  def primaryKeyField = id
>
>  object id extends MappedLongIndex(this)
>
>  object parent extends MappedLongForeignKey(this, Parent)
> }
>
> What do I need to do so that I could do something like
>
> parent.children.map(...)
>
> Only way I have figured out is to create function like one below in
> the Parent class. That will only solve problem of finding and updating
> them, not adding, deleting or so.
>
>  def children = Child.findAll(By(Child.parent, this.id))
>
> There probably is a correct way to do this, but at least I couldn't
> find it. Any help appreciated.
>
> Thanks beforehand,
>  Juha
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to