On Tue, Jan 5, 2010 at 11:51 AM, Mads Hartmann <mads...@gmail.com> wrote:
> Sure thing, it's quite long though :) > > Just one thing, i added the following for it to compile (I want to > return List[User] not List[TagUser] : .map(_.user.obj.open_!) > > So in all it looks like this > > def getTopUsers(in: Int) :List[User] = { > > TagUser.findAll(By(TagUser.tag, this.id), In(TagUser.user, User.id, > OrderBy(User.followers_count, Descending), MaxRows[User](in))) > .map(_.user.obj.open_!) > > } > What version of Lift? > > Exception occured while processing / > Message: java.lang.NullPointerException > net.liftweb.mapper.In$$anon$3.<init>(MetaMapper.scala:1206) > net.liftweb.mapper.In$.apply(MetaMapper.scala:1200) > scalableKvidr.model.Tag.getTopUsers(Tag.scala:38) > scalableKvidr.snippet.TagsSnippets$$anonfun$frontpageTags$1.apply > (TagsSnippets.scala:71) > scalableKvidr.snippet.TagsSnippets$$anonfun$frontpageTags$1.apply > (TagsSnippets.scala:68) > scala.List.flatMap(List.scala:1125) > scalableKvidr.snippet.TagsSnippets.frontpageTags(TagsSnippets.scala: > 67) > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > sun.reflect.NativeMethodAccessorImpl.invoke > (NativeMethodAccessorImpl.java:39) > sun.reflect.DelegatingMethodAccessorImpl.invoke > (DelegatingMethodAccessorImpl.java:25) > java.lang.reflect.Method.invoke(Method.java:597) > > net.liftweb.util.ClassHelpers$$anonfun$net$liftweb$util$ClassHelpers$ > $_invokeMethod$2$$anonfun$apply$7.apply(ClassHelpers.scala:352) > net.liftweb.util.ControlHelpers$class.tryo(ControlHelpers.scala:40) > net.liftweb.util.Helpers$.tryo(Helpers.scala:29) > net.liftweb.util.ControlHelpers$class.tryo(ControlHelpers.scala:55) > net.liftweb.util.Helpers$.tryo(Helpers.scala:29) > > net.liftweb.util.ClassHelpers$$anonfun$net$liftweb$util$ClassHelpers$ > $_invokeMethod$2.apply(ClassHelpers.scala:352) > > net.liftweb.util.ClassHelpers$$anonfun$net$liftweb$util$ClassHelpers$ > $_invokeMethod$2.apply(ClassHelpers.scala:352) > scala.Iterator$$anon$14.next(Iterator.scala:267) > scala.Iterator$class.find(Iterator.scala:462) > scala.Iterator$$anon$14.find(Iterator.scala:265) > net.liftweb.util.ClassHelpers$class.net$liftweb$util$ClassHelpers$ > $_invokeMethod(ClassHelpers.scala:353) > net.liftweb.util.ClassHelpers$class.invokeMethod(ClassHelpers.scala: > 285) > net.liftweb.util.Helpers$.invokeMethod(Helpers.scala:29) > net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$33$$anonfun > $apply$36$$anonfun$apply$38.apply(LiftSession.scala:723) > net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$33$$anonfun > $apply$36$$anonfun$apply$38.apply(LiftSession.scala:705) > net.liftweb.util.EmptyBox.openOr(Box.scala:372) > net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$33$$anonfun > $apply$36.apply(LiftSession.scala:705) > net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$33$$anonfun > $apply$36.apply(LiftSession.scala:705) > net.liftweb.util.EmptyBox.openOr(Box.scala:372) > net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$33.apply > (LiftSession.scala:704) > net.liftweb.http.LiftSession$$anonfun$17$$anonfun$apply$33.apply > (LiftSession.scala:704) > net.liftweb.http.S$.doSnippet(S.scala:725) > > net.liftweb.http.LiftSession$$anonfun$17.apply(LiftSession.scala:702) > > net.liftweb.http.LiftSession$$anonfun$17.apply(LiftSession.scala:701) > net.liftweb.util.Full.map(Box.scala:330) > net.liftweb.http.LiftSession.net$liftweb$http$LiftSession$ > $processSnippet(LiftSession.scala:701) > net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing > $1.apply(LiftSession.scala:793) > net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing > $1.apply(LiftSession.scala:777) > net.liftweb.util.NamedPF.apply(NamedPartialFunction.scala:30) > net.liftweb.util.NamedPF$.apply(NamedPartialFunction.scala:76) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$ > $anonfun$apply$49.apply(LiftSession.scala:808) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$ > $anonfun$apply$49.apply(LiftSession.scala:808) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$.setVars(S.scala:623) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude > $1.apply(LiftSession.scala:808) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude > $1.apply(LiftSession.scala:805) > scala.Seq$class.flatMap(Seq.scala:294) > scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) > net.liftweb.http.LiftSession.processSurroundAndInclude > (LiftSession.scala:804) > net.liftweb.http.LiftSession.net$liftweb$http$LiftSession$ > $processSurroundElement(LiftSession.scala:948) > net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing > $1.apply(LiftSession.scala:784) > net.liftweb.http.LiftSession$$anonfun$_defaultLiftTagProcessing > $1.apply(LiftSession.scala:777) > net.liftweb.util.NamedPF.apply(NamedPartialFunction.scala:30) > net.liftweb.util.NamedPF$.apply(NamedPartialFunction.scala:76) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$ > $anonfun$apply$49.apply(LiftSession.scala:808) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude$1$ > $anonfun$apply$49.apply(LiftSession.scala:808) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$.setVars(S.scala:623) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude > $1.apply(LiftSession.scala:808) > net.liftweb.http.LiftSession$$anonfun$processSurroundAndInclude > $1.apply(LiftSession.scala:805) > scala.Seq$class.flatMap(Seq.scala:294) > scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) > net.liftweb.http.LiftSession.processSurroundAndInclude > (LiftSession.scala:804) > net.liftweb.http.LiftSession$$anonfun$8.apply(LiftSession.scala:462) > net.liftweb.http.LiftSession$$anonfun$8.apply(LiftSession.scala:462) > net.liftweb.util.Full.map(Box.scala:330) > net.liftweb.http.LiftSession.processRequest(LiftSession.scala:462) > net.liftweb.http.LiftServlet.net$liftweb$http$LiftServlet$ > $dispatchStatefulRequest(LiftServlet.scala:244) > net.liftweb.http.LiftServlet$$anonfun$2.apply(LiftServlet.scala:176) > net.liftweb.http.LiftServlet$$anonfun$2.apply(LiftServlet.scala:176) > net.liftweb.http.S$.net$liftweb$http$S$$wrapQuery(S.scala:398) > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit$1$ > $anonfun$apply$16.apply(S.scala:453) > net.liftweb.http.S$.net$liftweb$http$S$$doAround(S.scala:372) > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$doAround$1.apply > (S.scala:373) > net.liftweb.mapper.DB$$anon$1.net$liftweb$mapper$DB$$anon$$doWith > (DB.scala:117) > net.liftweb.mapper.DB$$anon$1$$anonfun$net$liftweb$mapper$DB$$anon$ > $doWith$1.apply(DB.scala:118) > net.liftweb.mapper.DB$$anon$1$$anonfun$net$liftweb$mapper$DB$$anon$ > $doWith$1.apply(DB.scala:118) > net.liftweb.mapper.DB$.use(DB.scala:305) > net.liftweb.mapper.DB$$anon$1.net$liftweb$mapper$DB$$anon$$doWith > (DB.scala:118) > net.liftweb.mapper.DB$$anon$1.apply(DB.scala:124) > net.liftweb.http.S$.net$liftweb$http$S$$doAround(S.scala:373) > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit > $1.apply(S.scala:451) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$.net$liftweb$http$S$$_nest2InnerInit(S.scala:450) > > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun > $apply$19$$anonfun$apply$20$$anonfun$apply$21$$anonfun$apply$22$ > $anonfun$apply$23$$anonfun$apply$24.apply(S.scala:471) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun > $apply$19$$anonfun$apply$20$$anonfun$apply$21$$anonfun$apply$22$ > $anonfun$apply$23.apply(S.scala:470) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun > $apply$19$$anonfun$apply$20$$anonfun$apply$21$$anonfun$apply$22.apply > (S.scala:469) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun > $apply$19$$anonfun$apply$20$$anonfun$apply$21.apply(S.scala:468) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun > $apply$19$$anonfun$apply$20.apply(S.scala:467) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun > $apply$19.apply(S.scala:466) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1.apply > (S.scala:465) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$.net$liftweb$http$S$$_innerInit(S.scala:464) > net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$27$$anonfun$apply > $28$$anonfun$apply$29$$anonfun$apply$30.apply(S.scala:495) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$27$$anonfun$apply > $28$$anonfun$apply$29.apply(S.scala:494) > net.liftweb.http.RequestVarHandler$.apply(Vars.scala:191) > net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$27$$anonfun$apply > $28.apply(S.scala:493) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$27.apply(S.scala: > 492) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$$anonfun$_init$1.apply(S.scala:491) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.S$._init(S.scala:490) > net.liftweb.http.S$.init(S.scala:334) > net.liftweb.http.LiftServlet.doService(LiftServlet.scala:175) > net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply > (LiftServlet.scala:104) > net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply > (LiftServlet.scala:104) > net.liftweb.util.TimeHelpers$class.calcTime(TimeHelpers.scala:241) > net.liftweb.util.Helpers$.calcTime(Helpers.scala:29) > net.liftweb.util.TimeHelpers$class.logTime(TimeHelpers.scala:250) > net.liftweb.util.Helpers$.logTime(Helpers.scala:29) > net.liftweb.http.LiftServlet.doIt$1(LiftServlet.scala:103) > net.liftweb.http.LiftServlet.service(LiftServlet.scala:112) > net.liftweb.http.LiftFilterTrait$$anonfun$doFilter$1$$anonfun$apply > $22.apply(LiftServlet.scala:525) > net.liftweb.http.LiftFilterTrait$$anonfun$doFilter$1$$anonfun$apply > $22.apply(LiftServlet.scala:525) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.URLRewriter$.doWith(Req.scala:390) > net.liftweb.http.LiftFilterTrait$$anonfun$doFilter$1.apply > (LiftServlet.scala:524) > net.liftweb.http.LiftFilterTrait$$anonfun$doFilter$1.apply > (LiftServlet.scala:518) > > net.liftweb.http.RequestVarHandler$$anonfun$apply$3$$anonfun$apply$4$ > $anonfun$apply$5$$anonfun$apply$6.apply(Vars.scala:197) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.RequestVarHandler$$anonfun$apply$3$$anonfun$apply$4$ > $anonfun$apply$5.apply(Vars.scala:196) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.RequestVarHandler$$anonfun$apply$3$$anonfun$apply > $4.apply(Vars.scala:195) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > > net.liftweb.http.RequestVarHandler$$anonfun$apply$3.apply(Vars.scala: > 194) > net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) > net.liftweb.http.RequestVarHandler$.apply(Vars.scala:193) > net.liftweb.http.LiftFilterTrait$class.doFilter(LiftServlet.scala: > 517) > net.liftweb.http.LiftFilter.doFilter(LiftServlet.scala:536) > org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter > (ServletHandler.java:1157) > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java: > 388) > org.mortbay.jetty.security.SecurityHandler.handle > (SecurityHandler.java:216) > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java: > 182) > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java: > 765) > > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) > org.mortbay.jetty.handler.ContextHandlerCollection.handle > (ContextHandlerCollection.java:230) > org.mortbay.jetty.handler.HandlerCollection.handle > (HandlerCollection.java:114) > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java: > 152) > org.mortbay.jetty.Server.handle(Server.java:326) > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java: > 542) > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete > (HttpConnection.java:923) > org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547) > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) > org.mortbay.io.nio.SelectChannelEndPoint.run > (SelectChannelEndPoint.java:409) > org.mortbay.thread.QueuedThreadPool$PoolThread.run > (QueuedThreadPool.java:582) > > On Jan 5, 8:34 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote: > > On Tue, Jan 5, 2010 at 11:33 AM, Mads Hartmann <mads...@gmail.com> > wrote: > > > Thanks David, > > > It compiled just fine but I got a nullpointer exception for some > > > reason. > > > > Please post the stack trace. > > > > > > > > > > > > > For now I'll use the findAllByPreparedStatement method instead > > > so I can play along with my project. > > > > > Thanks for the help though :) > > > > > On Jan 5, 6:01 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote: > > > > Lift uses the SQL IN statement rather than joins. This has a > negative > > > > impact for users of MySQL and Derby. > > > > > > Try: > > > > > > TagUser.findAll(By(TagUser.tag, this), In(TagUser.user, User.id, > > > > OrderBy(User.followers_count, Descending), MaxRows[User](10))) > > > > > > On Mon, Jan 4, 2010 at 11:10 PM, Mads Hartmann <mads...@gmail.com> > > > wrote: > > > > > My ultimate goal would be to only pull out the top x users. I'm > > > > > currently using the following code to achieve this: > > > > > > > TagUser.findAll(By(TagUser.tag, this.id)).map(_.user.obj.open_!) > > > > > .sort(_.followers_count.is > _.followers_count.is) > > > > > .take(x) > > > > > > > But im concerned that this creates an instance for each of the > users > > > > > in tag tag even though i only need the top x. > > > > > > > Thanks for helping me out :) > > > > > > > On Jan 5, 1:47 am, David Pollak <feeder.of.the.be...@gmail.com> > wrote: > > > > > > On Mon, Jan 4, 2010 at 3:24 PM, Mads Hartmann <mads...@gmail.com > > > > > wrote: > > > > > > > Hello, I'm having a problem and I'm sure it's an easy fix for > > > someone > > > > > > > with a bit more experience > > > > > > > > > I have 3 model classes: tag, user, tweet and a join class > TagUser. > > > A > > > > > > > tag has a list of users. > > > > > > > > > If i want all of the users in a tag i use the following code > (which > > > > > > > works): > > > > > > > > > def users = TagUser.findAll(By(TagUser.tag, this.id)).map > > > > > > > (_.user.obj.open_!) > > > > > > > > > my problem is that i can't figure out how to apply queryparams > so i > > > > > > > don't pull out all of the users from the DB if i don't need em. > I > > > was > > > > > > > thinking something like this (doesn't compile): > > > > > > > > > def getTopUsers(in: Int) :List[User] = { > > > > > > > TagUser.findAll(By(TagUser.tag, this.id), > > > > > > > OrderBy(User.followers_count, > Descending), > > > > > > > MaxRows(in)) > > > > > > > > There is an issue: > > > > > > > > OrderBy(User.xxxx, Descending) // illegal... you can only order > by a > > > > > > TagUser.xxx field > > > > > > > > And a potential issue: > > > > > > > > MaxRows[TagUser](in) // sometimes the Type Inferencer doesn't get > it > > > > > right. > > > > > > > > What's your ultimate goal? > > > > > > > > > } > > > > > > > > > I get the following error: > > > > > > > [ERROR] ... error: overloaded method value findAll with > > > alternatives > > > > > > > > (net.liftweb.mapper.QueryParam[scalableKvidr.model.TagUser]*)List > > > > > > > [scalableKvidr.model.TagUser] <and> ()List > > > > > > > [scalableKvidr.model.TagUser] cannot be applied to > > > > > > > (net.liftweb.mapper.Cmp > > > > > > > [scalableKvidr.model.TagUser,Long],net.liftweb.mapper.OrderBy > > > > > > > > [scalableKvidr.model.User,Int],net.liftweb.mapper.MaxRows[Nothing]) > > > > > > > > > -- > > > > > > > > > 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<liftweb%2bunsubscr...@googlegroups.com> > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>> > > > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com> > <liftweb%252bunsubscr...@googlegroup s.com>> > > > > > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com> > <liftweb%252bunsubscr...@googlegroup s.com> > > > <liftweb%252bunsubscr...@googlegroup s.com>> > > > > > > > . > > > > > > > For more options, visit this group at > > > > > > >http://groups.google.com/group/liftweb?hl=en. > > > > > > > > -- > > > > > > Lift, the simply functional web frameworkhttp://liftweb.net > > > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > > > > > Follow me:http://twitter.com/dpp > > > > > > Surf the harmonics > > > > > > > -- > > > > > > > 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<liftweb%2bunsubscr...@googlegroups.com> > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>> > > > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com> > <liftweb%252bunsubscr...@googlegroup s.com>> > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/liftweb?hl=en. > > > > > > -- > > > > Lift, the simply functional web frameworkhttp://liftweb.net > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > > > Follow me:http://twitter.com/dpp > > > > Surf the harmonics > > > > > -- > > > 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<liftweb%2bunsubscr...@googlegroups.com> > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/liftweb?hl=en. > > > > -- > > Lift, the simply functional web frameworkhttp://liftweb.net > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > Follow me:http://twitter.com/dpp > > Surf the harmonics > > -- > 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<liftweb%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics--
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.