I have just discovered that the ignite hibernate layer 2 cache region
factory does something weird with tracking changes - the wrong
regions/caches were being updated  -  I would end up with cache entries for
other regions in one region.

for example if I say loaded updated a product entity then updated a
customer entity the product cache could contain the update to the customer.

It looks like someone didn't finish the implementation as there was a note
in source : /** Map needed to provide the same transaction context for
different regions. */

So I made the following two lines of change in
modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory

Line 102 in 1.8 :

-    private final ThreadLocal threadLoc = new ThreadLocal();
+    private ConcurrentMap<String, ThreadLocal> threadLocMap = new
ConcurrentHashMap<>();

Line 222 in 1.8 :

     ThreadLocal threadLocalForCache(String cacheName) {
-        return threadLoc;
+        return threadLocMap.computeIfAbsent(cacheName, (k)->new
ThreadLocal());;
     }


Cameron

Reply via email to