So if problem the same for all transactional cache-provider, i think maybe transaction-strategy should be fixed.
This issue is reproducible on all cache concurrency strategies - not only on TRANSACTIONAL
Here's my test case (using Spring and JPA):
@Test public void testL2Cache() throws Exception { final List<Long> holder = new ArrayList<Long>(); transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { Person p = new Person(); p.setName("person1"); em.persist(p); holder.add(p.getId()); em.flush(); em.clear(); em.find(Person.class, holder.get(0)); status.setRollbackOnly(); } }); transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { Assert.assertNull(em.find(Person.class, holder.get(0))); // FAILS HERE IF CACHE IS ENABLED } }); }
This issue is reproducible on all cache concurrency strategies - not only on TRANSACTIONAL
Here's my test case (using Spring and JPA):