File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Deleting parent->child with inverse foreignkey
Joined: Nov 20, 2008
Jun 24, 2011 02:49:39
i've run into a small problem.
It might be that the solution is obvious, and i just don't see it.
I have a bunch on tables.
PARENT( ID NUMBER(19,0), CHILD1_ID NUMBER(19,0), CHILD2_ID NUMBER(19,0), CHILD3_ID NUMBER(19,0) CONSTRAINT "FK_Parent_CHILD1_ID" FOREIGN KEY ("CHILD1") REFERENCES "CHILD1" ("ID") CONSTRAINT "FK_Parent_CHILD2_ID" FOREIGN KEY ("CHILD2") REFERENCES "CHILD2" ("ID") CONSTRAINT "FK_Parent_CHILD3_ID" FOREIGN KEY ("CHILD3") REFERENCES "CHILD3" ("ID") ) CHILD1( ID NUMBER(19,0) ) CHILD2( ID NUMBER(19,0) ) CHILD3( ID NUMBER(19,0) )
I wish to delete a row from the PARENT table, and each corresponding rows from the 3 CHILDX tables.
If the relationship was the other way around, i would just smack a ON DELETE CASCADE constraint on, and live happily ever after.
Does anyone have a suggestion which could point me in the right direction?
I know i essentially have 3 parents and 1 child here, and that the best solution would probably be to inverse the relationship, but this is unfortunatly not an option for me.
btw this is on Oracle Database 11g Enterprise Edition Release 126.96.36.199.0 if that matters
Thank you in advance for your time.
Joined: Nov 20, 2008
Jun 27, 2011 06:53:19
In the end i solved this using a stored procedure.
Its not really how i wanted to go around it, and from a maintanance point of view its awefull, but given that the structure had a great amount of tables i saw no other choice.
I agree. Here's the link:
subject: Deleting parent->child with inverse foreignkey
Best way to join a parent with many child tables yet preserving all parent table rows
URGENT :- Creating JTree
one to one unidirectional mapping in jpa
Tree with parents
update while doing save in hibernate
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015