Wow, I've just seen this post! Thats some sweet sugar... what's the ETA on scala 2.7.2 final and when lift will be merging the master with the 2.7.2 branch? IMO, its improvements like this which make great technologies like JPA accessible - great work guys
Cheers Tim On 15 Oct 2008, at 12:37, Derek Chen-Becker wrote: > Jorge, that's great news! Having to use the classOf definitely felt > a little clunky so this will help clean things up a lot. The > "undocumented and experimental" part scares me a little, but if this > will eventually be core functionality I think we'll definitely move > to it. > > Thanks, > > Derek > > On Wed, Oct 15, 2008 at 1:49 AM, Jorge Ortiz <[EMAIL PROTECTED]> > wrote: > Derek, > > With the upcoming release of 2.7.2, you can update all this > classOf[T] stuff to use scala.reflect.Manifest[T], which handles all > that stuff for you almost automagically. > > I've been meaning to blog about this, but haven't found the time. > The short example is: > > def find[A](id: Any)(implicit m: scala.reflect.Manifest[A]) = > em.find[A](m.erasure, id).asInstanceOf[A] > > Which can be invoked as: > > val user = find[User](userId) > > The compiler will fill in the implicit Manifest parameter for you. > Manifest represents a Scala type. You can test two Manifests for > subtype and supertype relationships. You can also call "erasure" on > a Manifest to get the Java Class corresponding to the runtime > erasure of that type. > > Manifests are undocumented and experimental, so proceed with > caution. Eventually they'll be the backbone of a native Scala > reflection API (yay!) > > --j > > > On Tue, Oct 14, 2008 at 6:13 PM, Derek Chen-Becker <[EMAIL PROTECTED] > > wrote: > You can just do Model.find(classOf[User], userId) and the type on > the method will be inferred. Any time you see a Class[A] parameter, > it wants the result of a classOf[...]. > > Derek > > > On Tue, Oct 14, 2008 at 5:52 PM, Charles F. Munat <[EMAIL PROTECTED]> > wrote: > > A question from the JPADemo... > > How does one use this: > > def find[A](clazz: Class[A], id: Any) = > em.find[A](clazz, id).asInstanceOf[A] > > If I have a User model and I want to use find on the EntityManager, > what > goes where the *** is below: > > val user = Model.find[User]( ***, userId) > > Thanks, > > Chas. > > > > > > > > > > Tim Perrett print application architect t: +44 (0) 78144 34 791 e: [EMAIL PROTECTED] w: timperrett.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
