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

Bouiaw (JIRA) noreply at atlassian.com
Sun Apr 17 16:11:59 EDT 2011


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

Bouiaw commented on HHH-3008:
-----------------------------

Same issue for me with H2 and Hibernate 3.6.3.Final.
Even with updatable=true, it does not work.

> Cascade delete does not work with unidirectional @OneToMany and @JoinTable
> --------------------------------------------------------------------------
>
>                 Key: HHH-3008
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3008
>             Project: Hibernate Core
>          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