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?

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

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to