mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 16:44:57 +00:00
HHH-10163 QueryResultsRegion is not invalidated from evictAll()
This commit is contained in:
parent
6b8c302494
commit
957a210610
@ -64,7 +64,7 @@ public abstract class BaseTransactionalDataRegion
|
||||
private Strategy strategy;
|
||||
|
||||
protected enum Strategy {
|
||||
VALIDATION, TOMBSTONES, VERSIONED_ENTRIES
|
||||
NONE, VALIDATION, TOMBSTONES, VERSIONED_ENTRIES
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,6 +89,16 @@ public BaseTransactionalDataRegion(
|
||||
&& !configuration.transaction().autoCommit();
|
||||
// TODO: make these timeouts configurable
|
||||
tombstoneExpiration = InfinispanRegionFactory.PENDING_PUTS_CACHE_CONFIGURATION.expiration().maxIdle();
|
||||
if (!isRegionAccessStrategyEnabled()) {
|
||||
strategy = Strategy.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if this region is accessed through RegionAccessStrategy, false if it is accessed directly.
|
||||
*/
|
||||
protected boolean isRegionAccessStrategyEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -182,9 +192,10 @@ public long getLastRegionInvalidation() {
|
||||
@Override
|
||||
protected void runInvalidation(boolean inTransaction) {
|
||||
if (strategy == null) {
|
||||
return;
|
||||
throw new IllegalStateException("Strategy was not set");
|
||||
}
|
||||
switch (strategy) {
|
||||
case NONE:
|
||||
case VALIDATION:
|
||||
super.runInvalidation(inTransaction);
|
||||
return;
|
||||
@ -247,9 +258,10 @@ private void removeEntries(boolean inTransaction, KeyValueFilter filter) {
|
||||
@Override
|
||||
public Map toMap() {
|
||||
if (strategy == null) {
|
||||
return Collections.EMPTY_MAP;
|
||||
throw new IllegalStateException("Strategy was not set");
|
||||
}
|
||||
switch (strategy) {
|
||||
case NONE:
|
||||
case VALIDATION:
|
||||
return super.toMap();
|
||||
case TOMBSTONES:
|
||||
|
@ -74,6 +74,12 @@ public QueryResultsRegionImpl(AdvancedCache cache, String name, TransactionManag
|
||||
if (transactional) {
|
||||
log.warn("Use non-transactional query caches for best performance!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRegionAccessStrategyEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,10 +42,7 @@
|
||||
import org.jboss.logging.Logger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests of QueryResultRegionImpl.
|
||||
@ -379,6 +376,18 @@ public void run() {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10163")
|
||||
public void testEvictAll() throws Exception {
|
||||
withQueryRegion((sessionFactory, region) -> {
|
||||
withSession(sessionFactory, s -> region.put(s, KEY, VALUE1));
|
||||
withSession(sessionFactory, s -> assertEquals(VALUE1, region.get(s, KEY)));
|
||||
region.evictAll();
|
||||
withSession(sessionFactory, s -> assertNull(region.get(s, KEY)));
|
||||
assertEquals(Collections.EMPTY_MAP, region.toMap());
|
||||
});
|
||||
}
|
||||
|
||||
@Listener
|
||||
public class GetBlocker {
|
||||
private final CountDownLatch latch;
|
||||
|
Loading…
x
Reference in New Issue
Block a user