[Lift] Re: One-to-Many mappings with Lift ORM

2008-11-26 Thread Juha L

Ok, thanks for the information.

Is the idea to phase out mapper in favour of the Record/Field as soon
as it reaches mature stage? It seems from the list that there is lot
of active development on that area, so that isn't probably far in the
future.

// Juha

On Nov 24, 7:08 pm, David Pollak [EMAIL PROTECTED]
wrote:
 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 frameworkhttp://liftweb.net
 Collaborative Task Managementhttp://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 liftweb@googlegroups.com
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
-~--~~~~--~~--~--~---



[Lift] Re: One-to-Many mappings with Lift ORM

2008-11-26 Thread David Pollak
On Wed, Nov 26, 2008 at 11:12 AM, Juha L [EMAIL PROTECTED] wrote:


 Ok, thanks for the information.

 Is the idea to phase out mapper in favour of the Record/Field as soon
 as it reaches mature stage? It seems from the list that there is lot
 of active development on that area, so that isn't probably far in the
 future.


It's likely that Mapper will be the official ORM tool for Lift 1.0 and the
Record stuff will mature and be the recommended ORM tool for Lift 1.1+




 // Juha

 On Nov 24, 7:08 pm, David Pollak [EMAIL PROTECTED]
 wrote:
  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 frameworkhttp://liftweb.net
  Collaborative Task Managementhttp://much4.us
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp

 



-- 
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 liftweb@googlegroups.com
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
-~--~~~~--~~--~--~---