diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/CacheModeGetUpdateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/CacheModeGetUpdateTest.java index 70119bec9f7f..78676e54f7f0 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/CacheModeGetUpdateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/CacheModeGetUpdateTest.java @@ -13,6 +13,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.Jira; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.AfterAll; @@ -75,6 +76,22 @@ public void test(SessionFactoryScope scope) { } ); } + @Test + @Jira("https://hibernate.atlassian.net/browse/HHH-5689") + public void testRollback(SessionFactoryScope scope) { + scope.inTransaction( session -> { + final Phone phone = session.find( Phone.class, PHONE_ID ); + phone.setNumber( "456" ); + session.flush(); + session.markForRollbackOnly(); + } ); + // in a different transaction + scope.inTransaction( session -> { + final Phone phone = session.find( Phone.class, PHONE_ID ); + assertThat( phone.getNumber() ).isEqualTo( "123" ); + } ); + } + @Entity( name = "Phone" ) @Cacheable @Cache( usage = CacheConcurrencyStrategy.TRANSACTIONAL )