[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-2741) Deleting objects on inverse end of many to many relationship

Emmanuel Bernard (JIRA) noreply at atlassian.com
Wed Jul 25 00:00:52 EDT 2007


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

Emmanuel Bernard resolved HHH-2741.
-----------------------------------

    Resolution: Rejected

No this is the expected behavior. You need to clean the mappedBy side of the relationship before deleting. That's why it is mappedBy, it is not managed by the ORM.

> Deleting objects on inverse end of many to many relationship
> ------------------------------------------------------------
>
>                 Key: HHH-2741
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2741
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.1
>            Reporter: James Roper
>
> I have a Class, Stock, that has a bidirectional many to many indexed relationship with itself.  Here is the mapping:
>     @ManyToMany
>     @JoinTable(name = "input_output_stock", joinColumns = @JoinColumn(name = "id_output_stock"), inverseJoinColumns = @JoinColumn(name = "id_input_stock"))
>     @IndexColumn(name = "ix_input_stock")
>     @ForeignKey(name = "stock_output_fk", inverseName = "stock_input_fk")
>     private List<Stock> inputStock;
>     @ManyToMany(mappedBy = "inputStock")
>     private List<Stock> outputStock;
> When I delete stock objects, Hibernate runs the following queries:
> Hibernate: 
>     delete 
>     from
>         input_output_stock 
>     where
>         id_output_stock=?
> Hibernate: 
>     delete 
>     from
>         stock 
>     where
>         id=?
> This causes problems when deleting objects that are at the inverse end of the relationship.  Shouldn't Hibernate be running another query to delete where id_input_stock=?  As far as I can see in the Hibernate documentation and the EJB3 spec, there is no mention that this is the case.

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