Damn -
Thanks Armin. I have been ripping out my hair trying to figure this one out.
I appreciate it.
I guess I will have to change my implementation.
Also - for some reason, I can't get the P6Spy stuff to work either...
I have that listed as my driver, and I have the spy.properties file containing my realdriver class, but I get no debugging statements...
Any idea?
--Bobby


Armin Waibel wrote:

Hi Bobby,

Bobby Lawrence wrote:

OK - This is frustrating...
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.


Using an Array as collection reference is completely different from using a java-Collection. In the second case OJB can take care of removed objects when using e.g. RemovalAwareCollection/List for Collection/List fields. When using arrays this is not possible.
(in contrast to the odmg-api, the PB-api doesn't track object modifications, so to notice removed objects a specific collection implementation is needed for collection-reference fields).
Sorry I didn't notice that you are using an array before this post.


regards,
Armin


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?
I seems like the latter...


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).





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


-- ---------------------------- 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]



Reply via email to