Object A has many objects B. (OneToMany)
Object A is persistent in the database, and it have four objects B (B1, B2, B3, B4). I want remove B2, it's execute correctly in cache but how the object A has not changed, the changes in the database have not been executed.
I try A.setdirtyFlag, but nothing.
I has execute b2.remove or not ?
Saludos
Victor (Madrid - Spain)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Removing an object from a collection will not delete it from the database as it is possible that the object is referenced elsewhere, and that it is possible that the object is valid on its own.
To delete the object you will need to specifically call the delete() method.
For Object A, you have to make sure that the collection knows about it's parent or that the parent captures the events of the collection. There are two ways to do this:
1. Set the collections .Parent() property when the collection is instantiated. eg ObjBCol.Parent = Me
- or -
2. Capture the events on the collection and set Object A's dirty flag as needed (requires that the collection be declared as "withevents" in vb, or that you add events handlers)
- Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I has the following structure:
Object A has many objects B. (OneToMany)
Object A is persistent in the database, and it have four objects B (B1, B2, B3, B4). I want remove B2, it's execute correctly in cache but how the object A has not changed, the changes in the database have not been executed.
I try A.setdirtyFlag, but nothing.
I has execute b2.remove or not ?
Saludos
Victor (Madrid - Spain)
Hi,
the same problem with add a object
Saludos
Victor (Madrid - Spain)
Hi Victor,
Removing an object from a collection will not delete it from the database as it is possible that the object is referenced elsewhere, and that it is possible that the object is valid on its own.
To delete the object you will need to specifically call the delete() method.
For Object A, you have to make sure that the collection knows about it's parent or that the parent captures the events of the collection. There are two ways to do this:
1. Set the collections .Parent() property when the collection is instantiated. eg ObjBCol.Parent = Me
- or -
2. Capture the events on the collection and set Object A's dirty flag as needed (requires that the collection be declared as "withevents" in vb, or that you add events handlers)
- Richard