[hibernate-issues] [Hibernate-JIRA] Updated: (ANN-30) @OnDelete

Lajos Gathy (JIRA) noreply at atlassian.com
Fri Apr 17 06:19:17 EDT 2009


     [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-30?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lajos Gathy updated ANN-30:
---------------------------

    Attachment: Collection.java.diff

I ran into this problem not so long ago and tried to find a solution/workaround. I found that when I add an @OnDelete(action = OnDeleteAction.CASCADE) annotation to a @ManyToMany annotated getter I get the following exception: "only inverse one-to-many associations may use on-delete="cascade": ..."

This comes from org.hibernate.mapping.Collection.validate(Mapping). I modified this part (diff attached, based on hibernate core 3.3.0.SP1 source code... sorry, not the latest one, but I used this version). It seems to work, at least it generates the "on delete cascade" postfixes for the foreign keys (I use PostgreSQLDialect).

I understand that this is not even a change in Hibernate Annotations project but in Core, and I am not able to verify my solution with test cases, since I am not quite familiar with the source base of Hibernate. I just thought that I post my solution, since it seemed to me that the feature itself is implemented already in Hibernate, I just adjusted the validation not to fail.

If you find my solution working, please consider to put it into an upcoming release. Thanks in advance.

> @OnDelete
> ---------
>
>                 Key: ANN-30
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-30
>             Project: Hibernate Annotations
>          Issue Type: Improvement
>          Components: binder
>    Affects Versions: 3.1beta3
>            Reporter: Emmanuel Bernard
>            Assignee: Emmanuel Bernard
>            Priority: Trivial
>         Attachments: Collection.java.diff
>
>
> @OnDelete(type=OnDeleteType.NOACTION)
> OnDeleteType.CASCADE
> used on an indexed collection

-- 
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