db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <agalla...@agsoftware.dnsalias.com>
Subject Re: [Bug?] PBImpl delete of 1:n relation when auto-delete is set true
Date Sat, 06 Dec 2003 20:09:18 GMT
>>>1. auto-retrieve is set true and we query a Product, then we get all
>>>Components from Product and remove some components (or set components
>>>'null'). After this we delete this Product instance ---> auto-delete is
>>>true, thus all found components will be deleted (without the removed)
>>>BUT we should delete all components associated with this Product
>>> instance.
>>
>> Here the problem we see is you have not enabled the auto-update
>> attribute.
>>
> In my test case auto-update is true, but I think that is irrelevant.
> I will check in the test case ASAP.
>
>> Why? Because if you set to null an item in the collection this does not
>> mean: "Delete" it is just an update of the item.
> yes, in my test case I remove some collection objects, e.g. two from
> five. But when I delete the main object (containing the collection) I
> expect that all five objects will be deleted when the main object is
> deleted. Currently only three objects will be deleted and I get an DB
> constraint exception.

When you set them to null or get them out of the list, then PB cannot
access them and this is why PB only remove the 3 knowed.

Auto-retrieve is not trigged before a delete since it would be a penality
and can cause other problem, when you are updating. So it is not sense to
trigg auto-retrieve just before the delete action.
>
>> The default behavior of
>> auto-update is false, so PB does not do this automatically. This is why
>> they remains our if you configured constrains in the database the remove
>> can also fail, because there will be some register not deleted (the once
>> you setted to null and need to update because you have not enable the
>> auto-update attribute.
>>
>> In order to avoid the use of auto-update, please get the item out of the
>> collection. I think in that way auto-delete will do the work fine.
>>
>>
>>>2. auto-retrieve is set false. Get a Product and delete it. Since we set
>>>auto-delete true we expect that all associated Components will be
>>>deleted too.
>>
>> Hmm. Problem here is that the collections items are not retrieved, so PB
>> is not aware of them. This is why they stay in the database.
>>
> yep, but I expect that all dependend objects will be deleted when I set
> auto-delete true (independent from the other auto-XX attributes), or we
> need a more exact description of these attributes in doc.

How can PB know about the items in the collections if we not retrieve them?

PB works with at Java Bean level (based on the info stored on the bean).
PB cannot and I think it is not desirable (because of performance
penality) to retrieve the object from DB, compare with the current bean
and guess what are we what to do.

And what if we really just need to delete 3 of the object because the
other we already need update or attach to another object. Currently, I
cannot provide an example of that, but it can be requiered in a case.

I think the attributes behavior is correct as it is now, as you suggested
maybe the docs can be improved a little. Also, maybe some examples, will
help here.

Best Regards,

Antonio Gallardo


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message