Thomas Mahler wrote:
Hi Sebastian,
Did you read http://db.apache.org/ojb/tutorial3.html#Setting%20Load,%20Update,%20and%20Delete%20Cascading ?
You encounter the interference of two features here: the cascading operations feature and the removal-aware collection.
1. If you remove a Child and then delete the parent, The cascade feature does only delete those elements currently present in the collection.
2. If you remove a child and then store the parent, the removal aware collection notices that the removed child should be removed in the db too.
why don't we provide the same feature for insert ?
jakob
ALthough this all works as designed, I have to admit that it may be a bit confusing.
Maybe it would be more consistent, if we would change the semantics of 1. as follows:
If you remove a Child and then delete the parent, the cascading feature deletes the childs currently present in the collection and all removed child objects?
cu, Thomas
Sebastian wrote:
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]
--------------------------------------------------------------------- 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]
