[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3008) Cascade delete does not work with unidirectional @OneToMany and @JoinTable

Daniel Dyer (JIRA) noreply at atlassian.com
Wed Dec 12 12:46:56 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29143 ] 

Daniel Dyer commented on HHH-3008:
----------------------------------

OK, I'll have to try setting it to true and see if that makes any difference.

Do you believe this is the correct behaviour though?  Should "not updatable" mean "not removable"?  I don't believe that it should, but I am not familiar with the spec.

I tried replacing Hibernate with OpenJPA and that works as I would expect it to (the rows are removed).

> Cascade delete does not work with unidirectional @OneToMany and @JoinTable
> --------------------------------------------------------------------------
>
>                 Key: HHH-3008
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3008
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.5
>         Environment: Standalone entity manager (JavaSE 5.0).
> H2 database.
>            Reporter: Daniel Dyer
>
> A unidirectional one-to-many relationship defined as follows:
> public class Owner
> {
>     @OneToMany(cascade = CascadeType.ALL)
>     @JoinTable(name = "owner_element",
>                joinColumns = @JoinColumn(name = "owner_id",
>                                          nullable = false,
>                                          updatable = false),
>                inverseJoinColumns = @JoinColumn(name = "element_id",
>                                                 nullable = false,
>                                                 updatable = false))
>     private List<Element> elements;
>     // ...
> }
> Attempting to delete an instance of Owner should also delete all associated instances of Element.  Instead I get the following error:
> SEVERE: Referential integrity constraint violation: FK56BBF9C487E817D: PUBLIC.OWNER_ELEMENT FOREIGN KEY(OWNER_ID) REFERENCES PUBLIC.OWNER(ID) [23003-63]
> This is because Hibernate attempts to delete the Owner row without first removing the rows from the join table.

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