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.
Configuring XA transactions and have Infinispan participate in XA seems like overkill in this situation. Is XA the only way to address this?