[Lift] Re: net.liftweb.mapper.PreCache doesn't work well as my expect

2009-08-26 Thread koji

Thank you David,
I found that I'm using lift-1.0.
After i changed to 1.1 snapshot, it works well now.

thanks

On Aug 26, 5:32 am, David Pollak feeder.of.the.be...@gmail.com
wrote:
 PreCache works as expected.

 Here's the data model:

 class RoomChoice extends LongKeyedMapper[RoomChoice] with IdPK {
   def getSingleton = RoomChoice
   object name extends MappedPoliteString(this, 512)
   object price extends MappedInt(this){
     override def defaultValue = 0
   }

 }

 object RoomChoice extends RoomChoice with LongKeyedMetaMapper[RoomChoice]

 class User extends LongKeyedMapper[User] with IdPK {
   def getSingleton = User
   object account extends MappedPoliteString(this, 10)
   object roomChoice extends MappedLongForeignKey(this, RoomChoice)

 }

 object User extends User with LongKeyedMetaMapper[User]

 And here's the test:

     for {
       i - 1 to 50
     } {
     User.create.roomChoice(RoomChoice.create.name(Fog +i).saveMe).save
     }

     User.findAll(PreCache(User.roomChoice)).foreach{
       u = if (!u.roomChoice.cached_?) error(Failed +u)
     }

     User.findAll().foreach{
       u = if (u.roomChoice.cached_?) error(Failed +u)
     }

     val rooms =
 User.findAll(PreCache(User.roomChoice)).flatMap(_.roomChoice.obj)
     println(Rooms +rooms)

 I'm enclosing code the demonstrate the functionality.  Please let us know if
 there's something missing.

 Thanks,

 David



 On Mon, Aug 24, 2009 at 9:16 PM, koji koji@gmail.com wrote:

  Oops, so sorry for pasting wrong part.
  And sorry i didnt show my model's code
  my code is as below

  class RoomChoice extends LongKeyedMapper[RoomChoice] with IdPK {
      def getSingleton = RoomChoice
      object travel extends MappedLongForeignKey(this, Travel)
      object name extends MappedPoliteString(this, 512)
      object price extends MappedInt(this){
         override def defaultValue = 0
      }
  }
  class User extends LongKeyedMapper[User] with IdPK {
      def getSingleton = User
      object travel extends MappedLongForeignKey(this, Travel)
      object account extends MappedPoliteString(this, 10)
      object roomChoice extends MappedLongForeignKey(this,
  RoomChoice)
  }

  val users = User.findAll(By(User.travel, travelId),PreCache
  (User.roomChoice), OrderBy(User.id, Ascending))

  thank you

  On Aug 25, 6:40 am, Derek Chen-Becker dchenbec...@gmail.com wrote:
   Maybe I'm missing something, but you're telling Mapper to pre-cache
   User.roomChoice, but then you're accessing User.fromPlace. Are those two
   fields related somehow?

   Derek

   On Mon, Aug 24, 2009 at 12:25 AM, koji koji@gmail.com wrote:

Hi all,
I want to avoid n+1 problem
so i try to write my code as
val users = User.findAll(PreCache(User.roomChoice), By(User.travel,
travelId))
and i saw the sql generated only once for querying roomChoice.
but when i using the
u.fromPlace.obj, it always become Empty(u.fromPace has correct value)

thanks

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp

  precache.tgz
 7KViewDownload

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] net.liftweb.mapper.PreCache doesn't work well as my expect

2009-08-24 Thread koji

Hi all,
I want to avoid n+1 problem
so i try to write my code as
val users = User.findAll(PreCache(User.roomChoice), By(User.travel,
travelId))
and i saw the sql generated only once for querying roomChoice.
but when i using the
u.fromPlace.obj, it always become Empty(u.fromPace has correct value)

thanks


--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: the question abount HelloForm2 of example darwin

2009-07-28 Thread koji

Thank you Tim,
That helps me.

koji

On 7月28日, 上午6時40分, Timothy Perrett timo...@getintheloop.eu wrote:
 Hey Koji,

 So I took  a look at your problem and made an example, please check
 the code here under basic-forms:

 http://github.com/timperrett/lift-examples/tree/master

 I have a feeling that S.param used to work differently... lift assigns
 random names to the inputs at runtime for security, so doing S.param
 (whoField) wont get you anywhere anyways; IMHO this is a bug in the
 example, not your code. You might want to check my examples anyway
 though as i've made some changes and added comments you might find
 helpful.

 Cheers, Tim


--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] the question abount HelloForm2 of example darwin

2009-07-27 Thread koji

Hi, I'm trying the HelloForm2 of darwin example.
The second version of HelloForm2 that who var is RequestVar shows
correct on the rendered page, but always showing Empty in my console
using param(whofield). Am i do something wrong?

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: the question abount HelloForm2 of example darwin

2009-07-27 Thread koji

thx Tim,
I paste my code to the git.
here is the index.html http://gist.github.com/156445 and
HelloWorld.scala http://gist.github.com/156446
and param(whoField) always shows Empty

thanks, koji


On Jul 27, 10:45 pm, Timothy Perrett timo...@getintheloop.eu wrote:
 Hey koji,

 Perhaps this article will help:http://is.gd/sfyT

 Otherwise, can you post the code your using? (perhaps onto
 gist.github.com)

 Cheers, Tim

 On Jul 27, 11:11 am, koji koji@gmail.com wrote:



  Hi, I'm trying the HelloForm2 of darwin example.
  The second version of HelloForm2 that who var is RequestVar shows
  correct on the rendered page, but always showing Empty in my console
  using param(whofield). Am i do something wrong?

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---