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

Daniel Dyer (JIRA) noreply at atlassian.com
Tue Dec 11 10:01:27 EST 2007


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

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

Not sure if this is of interest, but while I was searching for information about this problem, I came across a similar issue in Glassfish (TopLink):

https://glassfish.dev.java.net/issues/show_bug.cgi?id=2991

> 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