OJB will NOT delete objects in the database that are no longer in my collection.
I have an object that stores an array of other objects as a collection-reference.
The collection-descirptor has attributes auto-update="object", auto-delete="object".
Now, when I remove objects from the array in the parent and call PersistenceBroker.store(parent), the objects that were in my array are NOT deleted in the database. What happens is, OJB simply updates the objects that it does have in the array.
If my array contains 3 objects, I remove one, OJB updates 2 and fails to delete the remaining 1.
Any ideas?
I have run out...
--Bobby
Robert r. Sanders wrote:
Bobby Lawrence wrote:
How does OJB handle collection references internally?
If I have an object that contains a collection of other objects, and I remove one, will OJB remove that same one from the database?
If you use that API correctly (see the tutorials), then yes, OJB with track changes to collections, etc... Typical setup is so that if you remove an object from a collection the foriegn key is removed in the DB, but the actual 'object'/row is still there unless you explicitly delete this. I can't remember off the top of my head, but I believe there is a configuration option (per-collection) to change this so a remove == a db delete.
Also - if I have a collection that contains only one object and I change the primary key, does OJB update that object or insert a new one?You should let OJB handle the primary (and foreign) keys for you; they end up being the items that OJB is using to track object identity, so the behavior that your seeing is not unexpected (changing the primary key essentially changes the object reference as far as the SQL portion of OJB is concerned).
I seems like the latter...
-- ---------------------------- Bobby Lawrence MIS Application Developer
Jefferson Lab (www.jlab.org)
Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 ----------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
