HHH-5690 : Entity cache after persist, flush, rollback (test case)

(cherry picked from commit dad4c64d56)

Conflicts:
	hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
This commit is contained in:
Gail Badner 2014-06-03 21:28:24 -07:00
parent 84871ef1de
commit 6f947f2ab0
1 changed files with 51 additions and 0 deletions

View File

@ -45,6 +45,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.stat.Statistics;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@ -221,6 +222,56 @@ public class BasicTransactionalTestCase extends AbstractFunctionalTestCase {
}
}
@Test
@TestForIssue( jiraKey = "HHH-5690")
public void testPersistEntityFlushRollbackNotInEntityCache() throws Exception {
Statistics stats = sessionFactory().getStatistics();
stats.clear();
Item item = null;
Transaction txn = null;
Session s = null;
beginTx();
try {
s = openSession();
txn = s.beginTransaction();
item = new Item();
item.setName( "steve" );
item.setDescription( "steve's item" );
s.persist( item );
s.flush();
setRollbackOnlyTx();
}
catch (Exception e) {
setRollbackOnlyTx( e );
}
finally {
commitOrRollbackTx();
s.close();
}
// item should not be in entity cache.
SecondLevelCacheStatistics slcs = stats.getSecondLevelCacheStatistics( Item.class.getName() );
assertTrue( slcs.getEntries().isEmpty() );
beginTx();
try {
s = openSession();
txn = s.beginTransaction();
item = (Item) s.get( Item.class, item.getId() );
assertNull( item );
txn.commit();
s.close();
}
catch (Exception e) {
setRollbackOnlyTx( e );
}
finally {
commitOrRollbackTx();
}
}
@Test
@FailureExpectedWithNewUnifiedXsd
public void testQueryCacheInvalidation() throws Exception {