[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2224) executeUpdate causes coarse cache invalidation

Patrick Kranz (JIRA) noreply at atlassian.com
Wed Mar 25 12:12:38 EDT 2009


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

Patrick Kranz commented on HHH-2224:
------------------------------------

Hi you two,

I don´t really understand what the problem is you guys are experiencing. The blog entry you mentioned (http://blog.hibernate.org/cgi-bin/blosxom.cgi/2005/07/19#dml-basic) explains why Hibernate behaves like it does. Basically it is because if you execute an update on the database Hibernate has no way of knowing which objects are obsolete. So, it invalidates the whole cache region. The other option would be to reload all the objects in the cache but this will happen anyway if you ask for those objects again since the regions is invalidated. So in my opinion, the behavior as is, is the preferred one.

Regarding your three options:
- If you know the ids of the objects you want to modify, you don´t need a bulk update operation. You can retrieve the objects from the 2nd level cache and manipulate them directly. Since they are in your cache no DB round trip is needed. The changes are in your cache and all is fine.
- If you start invalidating the objects yourself you will forget it somewhere, trust me, and you will end up with hard to find bugs or stale data but it will definitely be worse than the "performance loss" of another DB round trip.
- again, in this case, why not load the objects yourself and do the modification. seems like you are loosing yourself in the old "for someone with a hammer, every problem looks like a nail"-paradigm ;-)

Best regards,
Patrick

> executeUpdate causes coarse cache invalidation
> ----------------------------------------------
>
>                 Key: HHH-2224
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2224
>             Project: Hibernate Core
>          Issue Type: Improvement
>    Affects Versions: 3.2.0.ga
>         Environment: Hibernate 3.2.0.ga, Oracle 9.2
>            Reporter: Stefan Fleiter
>         Attachments: bulk_testcase.zip
>
>
> I am developing an application and want to mix bulk-updates
> with normal hibernate operations.
> The bulk updates work fine, but invalidate the whole region and I've found
> no possibility to prevent this.
> There would be 3 options to improve:
> - Invalidate only the modified objects if the ids where given as Query-parameters.
> - Let me deactivate the invalidation so I can invalidate the affected objects myself.
> - Transform the DML to a select to gather the objects to invalidate before executing the DML
> The reference documentation does not mention caching at all:
> http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#batch-direct
> The best documentation I've found is:
> http://blog.hibernate.org/cgi-bin/blosxom.cgi/2005/07/19#dml-basic
> Maybe this could be added to the reference documentation...
> I already posted this at the forum
> http://forum.hibernate.org/viewtopic.php?t=966775
> but did not get a single answer.
> I've attached a testcase for this.

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