On Tue, Aug 18, 2009 at 12:32 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk>wrote:
> > On Thu, Aug 13, 2009 at 5:12 PM, Derek Chen-Becker<dchenbec...@gmail.com> > wrote: > > You should be able to use the PreCache QueryParam to tell Mapper to > > pre-fetch the mapped object: > > > > > http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/mapper/PreCache.html > > Ok, time for a bonus question: Can this be extended to more than 1 level? You'd have to try it. ;-) I don't think Mapper officially supports multiple levels of precaching. > > > I have something similar to the following > > class Vehicle extends LongKeyedMapper[Vehicle] with IdPK { > object vehicleType extends MappedLongForeignKey(this, VehicleType) > } > > class VehicleType extends LongKeyedMapper[VehicleType] with IdPK { > object brand extends MappedLongForeignKey(this, Brand) > } > > class Brand extends LongKeyedMapper[Brand] with IdPK { > } > > When displaying the list of vehicles I need to show both the vehicle, > the vehicleType & the brand in the same table > > So to get the list of vehicles and caching the vehicletypes I do this: > > override def findForListParams: List[QueryParam[Vehicle]] = > List(By(account, User.currentUser.open_!.account.is), > PreCache(vehicleType)) > > But I still get the n+1 selects when trying to resolve > vehicleType.brand. Can this be remedied somehow? > > /Jeppe > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 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 liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---