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

rajesh kumar (JIRA) noreply at atlassian.com
Fri Jul 9 00:57:13 EDT 2010


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

rajesh kumar commented on HHH-2224:
-----------------------------------

Hi All,
I have found a solution to the problem described.
Hibernate provides a <synchronize> tag to specify what all are the tables that are affected becuase of the bulkupdate.

If we are specifying the <synchronize>with table name hibernate only invlidate the cache of the table present in the synchronize table.This will avoid clearning of all the cache regions including the read only cache.
For achieving this, <synchronize> should be added to the <sql-query> during a bulk update or a delete.

Eg:
<sql-query name="queryname">
     <synchronize table="tablename"/>
     update tablename set value = ?    
 </sql-query>

The synchronization should be done on the affected tables because of the update. There can be one or more synchronize tags within the same block depending on what all tables got affected. This will result in cache invalidation of only those tables which are synchronized; otherwise the entire cache region is invalidated.

Note: Hibernate does a flush of the pending data for synchronized tables (from insert/update queue) before actually doing the synchronization. So the flush is triggered automatically for those data in the insert/update/delete queues where the affected tables are synchronized.

We could get this documented in hibernate reference documentation.

 

> 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, hibernate-3.2.6_p4.patch
>
>
> 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