Re: Create dataobjects from classname in a table column

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue May 31 2005 - 14:45:29 EDT

  • Next message: McDaniel, Joe R.: "RE: Generated ID in 1.2?"

    Yeah, what Paul described is single table inheritance that Cayenne
    supports pretty well. What Cayenne doesn't support is dynamically
    instantiating unmapped classes...

    So whenever you create a new subclass in Java, just map it as an inherited
    ObjEntity in the Modeler with "qualifier" expression field matching on
    class name (e.g. "db:CLASSNAME = 'com.xyz.MySubclass'"). It shouldn't be a
    big deal.

    Andrus

    >>
    >> When I do a query or anything that accesses the rows, I would like
    >> Cayenne to return the specific implementation of CayenneDataObject
    >> listed in the table for that row, instead of the class listed in the
    >> xml map file.
    >>
    >> I've tried various means of getting Cayenne to recognize the child
    >> objects without any luck. I don't want to have to edit the xml map
    >> file each time we add a new row implementation. Is this sort of thing
    >> possible in Cayenne, or totally out of scope of the way it works?
    >>
    >
    > Check out the inheritence support:
    >
    > http://objectstyle.org/cayenne/userguide/dataobjects/dataobjects-inheritance.html
    >
    > It's not 100% automatic, but it should work for you.
    >
    > Cris



    This archive was generated by hypermail 2.0.0 : Tue May 31 2005 - 14:45:30 EDT