Dmitry Bedrin commented on Bug HHH-5689

For entities with Transactional caching strategy, updated data remains in 2L cache after transaction rollback.

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 testHHH5689() 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) {
                Person p = em.find(Person.class, holder.get(0));
                p.setName("person2");

                em.flush();
                em.clear();

                em.find(Person.class, holder.get(0));

                status.setRollbackOnly();
            }
        });

        transactionTemplate.execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                Assert.assertEquals("person1",em.find(Person.class, holder.get(0)).getName()); // FAILS HERE IF CACHE IS ENABLED
            }
        });

    }
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira