Clarify my question here:
suppose I have two table 
 create table A (
        id integer primary key
        );
 create table B (
        id integer primary key,
        idA integer not null,
        constraint FK_B_TO_A foreign key (idA) references A
(id) on delete cascade
        );
 Here suppose A to B is a one-to-many association 
 and I did not ask the hibernate to do the cascade in
the mapping file since I will do it in database by
 specifying "on delete cascade"; I think it will be
 effecient to let the database to do the cascading
 deletion. (Am I right here?).
 
 If I call Session.delete(A), the Session will issue
 these two queries:
 1. update B set idA = null where idA =?
 2. delete from A where id = ?

This causes some problem.
1. I specify the foreign key idA is not null. So the
first query will always fail.
2. Suppose I remove "not null" constraint on the
foreign key idA and ask the database to do the
cascading deletion. If hibernate sets the foreign key
to null, database will not be able to do the cascading
deletion since the key is NULL right now (not idA any
more).

It seems the only workable solution is: remove all not
null constraint on the foreign key and let hibernate
to manage the cascade deletion. 

Is there any way I can turn off the "set null " update
before deletion metioned above?

Thanks


jason.





__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to