persistence@glassfish.java.net

Re: [Fwd: [Issue 879] New - Improvements required to Cascade remove on ManyToMany]

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Tue, 15 Aug 2006 11:56:35 -0700

Hi Tom!

[Including the persistence alias in the discussion]

I hope you had a great vacation!

While investigating issue 879 I noticed, that the class
OneToManyMapping doesn't have to implement method
hasInverseConstraintDependency().

The dependencies corresponding to a OneToMany/ManyToOne relationship
are always added by the owning side, which is represented by the class
OneToOneMapping in TopLink, correct?

So, the dependencies are added twice, once from the owning, and once
from the non-owning side. It should be possible to remove this method,
letting OneToManyMapping fall back to the default implementation
returning 'false'. Would you agree?

Could you please also comment on my evaluation of issue 879? The
change in class ManyToManyMapping could be the fix for this issue.


For issue 699, I changed UnitOfWorkImpl to remove the ObjectChangeSets
for all objects that are to be deleted before updates/inserts are
processed in any case. I got the impression that the updates for
deleted objects are executed in order to prevent foreign key (unique
key) violations. Is this correct?

There's no database constraint forcing to nullify foreign keys for for
OneToMany relationships, before other updates happen. The same is true
for join table entires in case of ManyToMany relationships, which
don't need to be removed. The only case where nulling out the foreign
key is important is for OneToOne relationships, which might have a
unique constraint on the foreign key in the database. But as
dependencies within the same class can't be determinated anyway,
removing those updates should not make a difference. Please see the
attached UnitOfWorkImpl class for my change.

I ran entity-persistence-tests w/o regressions with my changes. What
do you think?

Thanks very much,

-- markus.


Tom Ware wrote:

> Hi Markus,
>
> I was on vacation, but it looks like you got your answer. Feel free
> to contact me with questions.
>
> -Tom
>
> Markus Fuchs wrote:
>
>> Hi Tom,
>>
>> is it ok if I look into this?
>>
>> Thanks!
>>
>> -- markus.
>>
>>
>