[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-605) @ContainedIn does not work on deletes.

Sanne Grinovero (JIRA) noreply at atlassian.com
Fri Oct 8 10:31:57 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38646#action_38646 ] 

Sanne Grinovero commented on HSEARCH-605:
-----------------------------------------

I agree with your point, it's sad that it's needed to change both parts of the Java collection, but really that's a limitation of the way collections are used; Hibernate can't do much about that.
Hibernate will use one or the other collection as "source" to apply modifications; the most simple strategy for user code to make sure that's going to happen is to mandate as best practice to always mandate both sides - this point is strongly stressed at all hibernate courses and books, so your best bet is make sure that all "helpers" in your code update both sides.
Of course, if you have an idea, we'll be glad to hear about it.

> @ContainedIn does not work on deletes.
> --------------------------------------
>
>                 Key: HSEARCH-605
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-605
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 3.2.1
>            Reporter: Kyrill Alyoshin
>
> So, let's say we have a @Indexed entity Vendor (the parent) that is in a bi-directional @OneToMany relationship with entity Address (the child). Vendor maps the collection of Address'es as @IndexedEmbedded. Address is NOT @Indexed but does map its parent vendor association as @ContainedIn. 
> Whenever Address entity is retrieved and session.delete'ed, the parent Vendor's index is NOT updated. Everything works fine with update operations. 
> This obviously happens because the collection of addresses in parent vendor still contains the deleted address. (If the deleted address is manually removed from collection, everything works fine). 
> Now... I realize that it is not in Hibernate style to automatically severe the association when a child entity is deleted. However, it seems that Hibernate Search should provide such functionality. This does lead to very subtle, hard to diagnose bugs. I assume when Vendor's collection is flushed it is fairly trivial to detect which addresses have been deleted and which not (inside the listener). 

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