-
1. Re: Persistence: @ManyToOne - how to set null referencing rows
niox.nikospara.yahoo.com Oct 21, 2009 3:33 PM (in response to kipod)Seam-generated projects contain some files named import-XXX.sql. These are run from Seam, every time at startup. You can put the code that checks if the constraint exists and creates it if not, in there.
-
2. Re: Persistence: @ManyToOne - how to set null referencing rows
kipod Oct 22, 2009 2:04 AM (in response to kipod)Hia Nikos, thanks for answering.
So your'e saying that in-code annotations don't have the power to express this ?
-
3. Re: Persistence: @ManyToOne - how to set null referencing rows
kipod Oct 22, 2009 2:25 AM (in response to kipod)Thing is that hbm2ddl creates stuff like:
KEY 'FK27346759528447' ('house_id'), CONSTRAINT 'FK27346759528447' FOREIGN KEY ('house_id') REFERENCES 'house' ('id')
in the Person tabls.
And if I add my own constraint via
ALTER TABLE person ADD CONSTRAINT my_contraint FOREIGN KEY (house_id) REFERENCES house (id) ON DELETE SET NULL;
- It creates ANOTHER constraint, and does not replace the old one.
What is the best way to go about this?
-
4. Re: Persistence: @ManyToOne - how to set null referencing rows
niox.nikospara.yahoo.com Oct 22, 2009 11:43 AM (in response to kipod)I am not sure if you can override Hibernate's schema creation code. You could however generate the DDL with hbm2ddl, then modify it by hand (or scripting somehow), and finally dump it in import.sql for execution. Or execute the modified DDL whenever there is need to do so, e.g. when installing or upgrading the application.
-
5. Re: Persistence: @ManyToOne - how to set null referencing rows
kipod Oct 22, 2009 2:30 PM (in response to kipod)Right on,
I'm gonna take the hbm2ddl's DDL and add my
on delete set null
stuff.
Then use this in order to create the db, manually, outside of Seam or the IDE.Thank you.
-
6. Re: Persistence: @ManyToOne - how to set null referencing rows
grendizer Dec 2, 2010 12:21 PM (in response to kipod)Hi Jarden, Hi Nikos,
I know the thread is old. Could you maybe tell me how did you solve this ? in details if possible.
Thanks in Advance
Jarden Mier wrote on Oct 22, 2009 14:30:
Right on,
I'm gonna take the hbm2ddl's DDL and add myon delete set null
stuff.
Then use this in order to create the db, manually, outside of Seam or the IDE.
Thank you.Click HELP for text formatting instructions. Then edit this text and check the preview.