开发者

SQL exception causes Hibernate second level cache to have stale data with Infinispan as the provider

We are using Infinispan (clustered using JGroups) as our second level cache in our JPA(Hibernate) based application. When a database operation fails, we see that the level-2 cache is stale. For example:

1) Attempt to create a user with login "joe." 2) Call persist(user); 3) persist fails due to database uniqueness constraint. 4) Do a find by id on login=joe (assuming login is the PK). 5) Hibernate returns joe user from Infinispan cache, even though database doesn't have it.

C开发者_高级运维onfiguring XA transactions and have Infinispan participate in XA seems like overkill in this situation. Is XA the only way to address this?


Enable transaction synchronization, much cheaper than XA.

See http://infinispan.blogspot.com/2011/06/faster-infinispan-based-second-level.html for more details.


I had to enable XA transactions by deploying Atomikos to keep the cache in sync. Other solutions did not work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜