Re: Temporary Objects

From: Peter Karich (peatha..ahoo.de)
Date: Tue Apr 10 2007 - 15:29:58 EDT

  • Next message: Mike Kienenberger: "Re: Temporary Objects"

    Hallo,

    thank you again: now I got it!
    I needed examples :-)

    > Well, if you can mark each entity with whether it's persistent or not,

    Yes.

    > 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);
    > }

    This defines me "persistent -> (non)persistent".

    > 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.
    Do you mean that "nonpersistent -> (non)persistent" will be complicated?
    Why? I can do the following:

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

           } else {
              super.addToManyTarget(obj, ....);
           }
        }
    }

    Would this work?

    > 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.

    I will not get the references in the nonpersistent-object-list, right?

    Another question: How does cayenne hold objects in memory?
    As a normal reference, as WeakReference or even as PhantomReference?

    Peter.



    This archive was generated by hypermail 2.0.0 : Tue Apr 10 2007 - 15:32:58 EDT