Re: Temporary Objects

From: Mike Kienenberger (mkienen..mail.com)
Date: Tue Apr 10 2007 - 10:49:45 EDT

  • Next message: Andrus Adamchik: "Re: AUto PK/ how to desactivate"

    Well, if you can mark each entity with whether it's persistent or not,
    you could do this:

    public void addToManyTarget(Object obj, ...)
    {
        if obj.isNonpersistent()
        {
            nonpersistentSet.add(obj);
        }
        else
        {
             super.addToManyTarget(obj, ....);
        }
    }

    public List getList()
    {
         List list = new ArrayList(super.getList())
         list.addObjects(nonPersistentSet);
    }

    Things get more complicated if you want to have reverse relationships
    set for your non-persistent objects. I have implemented a
    non-persistent object DAO using the Cayenne api for testing and
    development. It's not pretty, but it can be done.

    And that's not going to handle what happens if you try to do a query
    on object sets that are both persistent and non-persistent.

    On 4/10/07, peter karich <peatha..ahoo.de> wrote:
    > Hallo Mike,
    >
    > thank you for your reply.
    >
    > > I don't think you're going to find a good solution
    > > to this problem.
    > It's a pity...
    >
    > > Here's one thing you can try, though.
    > > Keep in your Entity classes two lists of objects.
    > > Add a second
    > > "non-persistent" list for managing your
    > > non-persistent objects in
    > > addition to the standard one for persistent objects.
    > > Then change
    > > your accessors so that they merge both lists and
    > > return that as the
    > > result.
    > >
    > > Thus, your app will see the merged list, but the
    > > Cayenne layer would
    > > only see the persistent object lists.
    > Sorry, I can't follow the whole of your explanation.
    > I understand that I would need merging of persistent
    > and nonpersistent objects.
    > But the problem is, that I have to do the following:
    > persistentObj.addToManyTarget(nonpersistentObj,
    > "misc", false);
    > and
    > nonpersistentObj.setToOneTarget(persistentObj, "misc",
    > false);
    >
    > I have to think about it again,
    > Peter Karich.
    >
    >
    >
    > ___________________________________________________________
    > Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
    >



    This archive was generated by hypermail 2.0.0 : Tue Apr 10 2007 - 10:50:23 EDT