db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <ar...@code-au-lait.de>
Subject Re: [Bug?] PBImpl delete of 1:n relation when auto-delete is set true
Date Sat, 06 Dec 2003 19:06:04 GMT
Hi Antonio,

Antonio Gallardo wrote:

> Hi Armin:
> 
> Third and (hope the last answer) :-D Sorry, but I think this is very
> important point and while I am trying to explain I am learnig too. I am
> reasoning this whith a friend while posting. Our view point are between
> lines:
Here my first attempt to answer ;-)

> 
> Armin Waibel dijo:
> 
>>Hi all,
>>
>>I think I found a bug? in PBImpl class on delete of the 1:n relations of
>>the main object when auto-delete is set true in metadata.
>>
>>Say we have a Product class and a Component class, Product has a 1:n
>>relation to Component and we set auto-delete in collection-descriptor.
>>
>>Product
>>{
>>id
>>name
>>components
>>}
>>
>>Component
>>{
>>id
>>name
>>productId
>>}
>>
>>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.

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

regards,
Armin

> 
>>Or do I misinterpret the 'auto-delete' flag?
> 
> 
> 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
> 
> 
> 



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