superclass template question

From: Erik Hatcher (eri..hatchersolutions.com)
Date: Wed May 11 2005 - 10:50:12 EDT

  • Next message: Andrus Adamchik: "Re: Getting complex queries in cayenne"

    I want to generate something like this in each of my superclasses:

       static public final User forPK(Object pk) {
         return (User) DataObjectUtils.objectForPK(getCurrentDataContext
    (), User.class, pk);
       }

    First of all, is this approach reasonable to do? Are others doing
    something similar? getCurrentDataContext() comes from my custom base
    class and pulls the DataContext from thread local storage. My goal
    is to keep direct Cayenne dependence out of my Tapestry code, and for
    things like looking up an object by its primary key, I'd like to that
    to be clean and straightforward to use. My reliance on Cayenne will
    ideally be indirect as in the above finder method.

    Second - how can I get the package name of User when generating
    _User? I have superclasses generated into a separate package than
    the subclass objects (which I create manually).

    Thanks,
         Erik



    This archive was generated by hypermail 2.0.0 : Wed May 11 2005 - 10:50:57 EDT