Re: Code Generation

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Dec 13 2004 - 20:29:50 EST

  • Next message: Andrus Adamchik: "Re: Code Generation"

    On Dec 13, 2004, at 5:16 PM, Tore Halset wrote:

    > On Dec 13, 2004, at 16:14, Kevin J. Menard, Jr. wrote:
    >
    >> XMLDecoder decoder = new XMLDecoder();
    >> decoder.decode(xml);
    >> Test t = new Test(decoder);
    >
    > What if the found Test has the same primary key as another Test object
    > in the same DataContext? I think it would be easier if we have a
    > method returning the Test object based on the DataContext, the object
    > class and the xml.

    There are some interesting possibilities here, but I think we need to
    understand what problems we need to solve when adding DataContext (and
    Cayenne in general) to a very generic XML coding mechanism. Two apps
    that share the same DB and exchange messages between them is probably
    not a good example (you can just pass ObjectIds around). From my
    limited experience most common and useful cases of XML <-> ORM
    interaction are the following:

    1. XML Consumer app (webservice client): External XML feed -> Cayenne
    Application -> Database
    2. XML Producer app (webservice): Database -> Cayenne Application ->
    External XML Client

    (Am I missing any important cases?)

    Talking about decoding (case 1)... external XML feed may or may not
    have a DB PK value embedded in it. E.g. if you are reading XML data
    from UPS to create Shipment objects, shipment.shipment_id will be
    generated by Cayenne, and will not be present in the feed XML. So to
    match the XML with existing DataObjects we need to define some other
    criteria (e.g. match on a "trackingNumber" which is not a PK). If a
    matching object is found it should be updated from XML, if not - a new
    object should be created.

    So in this scenario there is a generic decode step, but matching and
    merging the data with existing DataObjects is something entirely
    different. Such matching mechanism is really an extension of the basic
    decoding... Would be cool if we can provide it in a generic fashion,
    but this shouldn't affect the decoder itself.

    Anyone can comment on that? Looks like we can built something cooler
    than what WebObjects provides ;-)

    > Test t = (Test)XMLDecoder.decode(dataContext, Test.class, xml);

    My thinking is probably affected too much by all the IoC hype, but my
    vote would be to use a decoder instance, not a static method.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Dec 13 2004 - 20:29:56 EST