[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-598) Add ON clause to @ForeignKey

Christian Bauer (JIRA) noreply at atlassian.com
Mon Aug 6 09:39:11 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27748 ] 

Christian Bauer commented on ANN-598:
-------------------------------------

Obviously instances in the current persistence context would be invalid after such a database side-effect of cascading. Which doesn't matter in most cases, because deletion happens just before the persistence context is closed anyway (in web conversations with persistence-context-per-conversation this is the normal pattern). The second-level cache obviously needs to be disabled for such entity associations.


> Add ON clause to @ForeignKey
> ----------------------------
>
>                 Key: ANN-598
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-598
>             Project: Hibernate Annotations
>          Issue Type: New Feature
>          Components: binder
>            Reporter: Christian Bauer
>
> More important than it sounds:
>     @org.hibernate.annotations.ForeignKey(name = "FK_FEED_DIRECTORY_ID")
> I need ON CASCADE DELETE on many of my foreign keys, so I have to do this right now via:
> <hibernate-mapping>
>     <database-object>
>         <create>
>             alter table FEED drop constraint FK_FEED_DIRECTORY_ID;
>             alter table FEED add constraint FK_FEED_DIRECTORY_ID foreign key (DIRECTORY_ID) references NODE on delete cascade;
>         </create>
>         <drop></drop>
>     </database-object>
> </hibernate-mapping>
> This is a bit annoying, especially since @JoinColumn(columnDefinition) is also not an option - I don't want to hardcode my HSQL datatypes.
> So we should accept a parameter on @ForeignKey (I know that the Hibernate binder doesn't have that notion at all, we need it in native Hibernate as well) that accepts "[ON {DELETE | UPDATE} {CASCADE | SET DEFAULT | SET NULL}];" and does the right thing during schema export.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list