Create dataobjects from classname in a table column

From: Paul Cowan (pwc2..ahoo.com)
Date: Tue May 31 2005 - 14:22:49 EDT

  • Next message: Cris Daniluk: "Re: Create dataobjects from classname in a table column"

    I'm working to convert a project based on an in-house developed ORM tool to
    Cayenne. It's amazingly similar to Cayenne but not nearly as fully featured.

    One thing we like to do but can't figure how in Cayenne, is dynamically create
    an object based on a classname stored in the database. Each table has a
    column named "CLASSNAME", which contains the full qualified classname of an
    object that represents the row, that extends a known abstract superclass, but
    implements some specific functionality that can not be modeled in a database.

    For example, a table that lists random number generators. Cayenne generated a
    superclass that extends CayenneDataObject, and I made the empty generated
    child class abstract and added an abstract getRandom() method. I then have
    various random number generator classes that implement getRandom(), like
    JavaMathRandomGenerator, MersenneTwisterGenerator, RandomDotOrgGenerator, etc.
     

    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?

    Thanks



    This archive was generated by hypermail 2.0.0 : Tue May 31 2005 - 14:22:51 EDT