You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Andy Czerwonka <cz...@arcticpenguin.ca> on 2003/09/27 17:12:46 UTC

Objects in referenced collection don't auto delete

Anyone see this before?

What I'd like is when I remove an object from a collection that is
referenced by another object, and then store() the object, I'd like the
collection to reflect that.  It doesn't seen to work.  The add worked
fine.

Failing Test
============
Person found = PersonHome.getInstance().find(person); // okay, got it.

PersonIdentifier identifier = (PersonIdentifier)
found.getPersonIdentifiers().toArray()[0]; // got the first object in
the collection

found.getPersonIdentifiers().remove(identifier); // remove it

PersistenceManager.storeInTransaction(person);  // store the 'updated'
object

PersistenceManager.clearCache();


found = PersonHome.getInstance().find(person);
assertTrue("Person has 0 PersonIdentifiers",
found.getPersonIdentifiers().size() == 0); // STILL THERE!!


-- 
andy


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Objects in referenced collection don't auto delete

Posted by Andy Czerwonka <cz...@arcticpenguin.ca>.
Something to do with the Cache I think.  BTW - broker.deleteByQuery
doesn't work but if I get a collection via the same query and delete
each object - works fine.

On Sat, 2003-09-27 at 09:12, Andy Czerwonka wrote:
> Anyone see this before?
> 
> What I'd like is when I remove an object from a collection that is
> referenced by another object, and then store() the object, I'd like the
> collection to reflect that.  It doesn't seen to work.  The add worked
> fine.
> 
> Failing Test
> ============
> Person found = PersonHome.getInstance().find(person); // okay, got it.
> 
> PersonIdentifier identifier = (PersonIdentifier)
> found.getPersonIdentifiers().toArray()[0]; // got the first object in
> the collection
> 
> found.getPersonIdentifiers().remove(identifier); // remove it
> 
> PersistenceManager.storeInTransaction(person);  // store the 'updated'
> object
> 
> PersistenceManager.clearCache();
> 
> 
> found = PersonHome.getInstance().find(person);
> assertTrue("Person has 0 PersonIdentifiers",
> found.getPersonIdentifiers().size() == 0); // STILL THERE!!
-- 
andy


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org