Hi,
I just discoverd the following behavior and I'm not sure if that works a
s designed. I'm using RC5.

That's the situation:

**********************************************************************
Class Parent
{
   int ID;
   RemovalAwareCollection childs = new RemovalAwareCollection();

   void removeChild(Child c)
   {
      childs.remove(c);
   }

   void addChild(Child c)
   {
      cholds.add(c);
   }
}

Class Child
{
   int ID;
   int parentID;
}

**********************************************************************
the Parent's collection descriptor for the childs property:
<collection-descriptor
   auto-retrieve="true" auto-delete="true" auto-update="true"
   refresh="true" name="childs"
collection-class="org.apache.ojb.broker.util.collections.RemovalAwareCollection"
   element-class-ref="Child"

  <inverse-foreignkey field-ref="parentID"/>
</collection-descriptor>

**********************************************************************
The problem:
When I add a child to the parent and store the parent, the child is also
written to the database. BUT when I then remove the child from the
parent's child collection and immediately delete the parent, the child
stays in the database table. On the opposite, when I store the parent
after I removed the child and then delete it the child is gone too.

This doesn't:
   Parent p = new Parent();
   Child c = new Child();
   p.addChild(c);
   broker.store(p);
   p.removeChild(c);
   broker.delete(p);
   //--> now the child is still in the table

This works:
   Parent p = new Parent();
   Child c = new Child();
   p.addChild(c);
   broker.store(p);
   p.removeChild(c);
   broker.store(p);
   broker.delete(p);

So my question is: is it ok the way OJB behaves or not?

Thanks in advance,
Sebastian



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



Reply via email to