Sebastian Stein escribió:
Vasily Ivanov <[EMAIL PROTECTED]> [060821 23:46]:
if I delete an ClassB object from the collection in
ClassA and store the ClassA object again, this
ClassB object is not removed from the database
It depends on how you delete this object from collection. You should
get object (aObject) with all references using OJB query, first. Than
remove object (bObject) from collection (by calling
aObject.getBs().remove(bObject)) and than call broker.store(aObject).
That should remove bObject from db.

I really don't understand why it is not working. I do the following:

aObject.getBs().clear();
aObject.getBs().addAll(newBs);

But the old Bs are not removed, just the new Bs are added. This is the case
if I have auto-delete="false" in the repository.xml for the definition of
the objectB collection.

If I turn it on, it deletes all Bs without adding them again. It is very
strange.

  Hi Sebastian.

  We had some similar situation, we solved in this way:

OBJ have a RemovalAwareList class, so i create a List usign RemovalAwareList(), copy the childs to this
  list, then remove the object from the list then i commit the changes.

  Example:
       List lst = new RemovalAwareList();
       lst.addAll(object1.getChilds());
       lst.remove(child);
object1.setChilds(lst); So when you commit your changes OJB delete the object.

  I hope this help.
Cheers, Carlos Chávez.
Sebastian

PS: If you are interested I can also point you directly to the code, it is
public.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to