use of org.hibernate.test.cache.infinispan.functional.entities.AccountHolder in project hibernate-orm by hibernate.
the class AccountDAO method getTotalBalance.
public int getTotalBalance(AccountHolder holder, boolean useRegion) throws Exception {
List results = (List) withTxSessionApply(useJta, sessionFactory, session -> {
Query query = session.createQuery("select account.balance from Account as account where account.accountHolder = ?");
query.setParameter(0, holder);
if (useRegion) {
query.setCacheRegion("AccountRegion");
}
query.setCacheable(true);
return query.list();
});
int total = 0;
if (results != null) {
for (Iterator it = results.iterator(); it.hasNext(); ) {
total += ((Integer) it.next()).intValue();
System.out.println("Total = " + total);
}
}
return total;
}
use of org.hibernate.test.cache.infinispan.functional.entities.AccountHolder in project hibernate-orm by hibernate.
the class TimestampsRegionImplTest method testClearTimestampsRegionInIsolated.
public void testClearTimestampsRegionInIsolated() throws Exception {
StandardServiceRegistryBuilder ssrb = createStandardServiceRegistryBuilder();
final StandardServiceRegistry registry = ssrb.build();
final StandardServiceRegistry registry2 = ssrb.build();
try {
final Properties properties = CacheTestUtil.toProperties(ssrb.getSettings());
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(registry, getCacheTestSupport());
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(registry2, getCacheTestSupport());
TimestampsRegionImpl region = (TimestampsRegionImpl) regionFactory.buildTimestampsRegion(getStandardRegionName(REGION_PREFIX), properties);
TimestampsRegionImpl region2 = (TimestampsRegionImpl) regionFactory2.buildTimestampsRegion(getStandardRegionName(REGION_PREFIX), properties);
Account acct = new Account();
acct.setAccountHolder(new AccountHolder());
region.getCache().withFlags(Flag.FORCE_SYNCHRONOUS).put(acct, "boo");
} finally {
StandardServiceRegistryBuilder.destroy(registry);
StandardServiceRegistryBuilder.destroy(registry2);
}
}
Aggregations