Re: localObjects() and MODIFIED objects, cloning DataObjects

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jan 19 2005 - 22:50:29 EST

  • Next message: Andrus Adamchik: "CAY-82 Ant DbGenerator"

    On Jan 19, 2005, at 2:40 PM, Mike Kienenberger wrote:

    > Is there a reason why a MODIFIED object couldn't be copied into a new
    > context?
    > I've never had the need to do it, but I don't see why it would be
    > disallowed.

    I agree - current behavior (throwing an exception) is probably not the
    best solution... I am in favor of changing that... The question is - do
    we want to copy a changed object, or a committed version of it? To be
    on a safe side, I'd say committed (but maybe there are valid cases for
    copying the changes as well?)

    > It'd require a new method call in localObjects to copy a DataObject.
    > We've
    > seen a number of requests to copy DataObjects pop up in the past on
    > the user
    > list, and I can't help but wonder if perhaps the ability to clone a
    > DataObject should be added to DataObjectUtils (or even to DataObject
    > itself).

    And with the whole POJO discussion this may become even more
    important... And I'd say copying not just a set of objects but a
    specified relationships as well, i.e. a piece of object graph. I am for
    adding this to DataObjectUtils for now, as I really hate to expand
    DataObject further until we settle on the whole POJO direction.

    > If so, I'd say it needs to support two versions: copy with same
    > objectId,
    > copy with new objectId.
    >
    > For relationships, I'd say just set them all as faults in the copy.
    >
    > And while we're on the subject, I think it'd be nice to provide
    > read-only
    > access to the CayenneDataObject values Map keys so an end-user can
    > iterate
    > through them.

    I am working on something called EntityDescriptor (in access package in
    CVS already) that looks like a good candidate for this task... This was
    initially intended for the use by ContextCommit and friends, but I hope
    this will eventually provide a usable facade to ObjEntity in general
    that will allow to quickly introspect a DataObject (or POJO) without
    getting into the whole attributes vs. relationships vs. DbAttributes
    mess. I guess we should add any needed extra methods to it and find an
    easily accessible place to put it (I guess EntityResolver).

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Jan 19 2005 - 22:50:35 EST