Skip to content

Commit ffafa1a

Browse files
committed
HHH-5689 Test rollback of flushed entity update and cache
1 parent ebd7a9e commit ffafa1a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/cache/CacheModeGetUpdateTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.hibernate.annotations.CacheConcurrencyStrategy;
1414

1515
import org.hibernate.testing.orm.junit.DomainModel;
16+
import org.hibernate.testing.orm.junit.Jira;
1617
import org.hibernate.testing.orm.junit.SessionFactory;
1718
import org.hibernate.testing.orm.junit.SessionFactoryScope;
1819
import org.junit.jupiter.api.AfterAll;
@@ -75,6 +76,22 @@ public void test(SessionFactoryScope scope) {
7576
} );
7677
}
7778

79+
@Test
80+
@Jira("https://hibernate.atlassian.net/browse/HHH-5689")
81+
public void testRollback(SessionFactoryScope scope) {
82+
scope.inTransaction( session -> {
83+
final Phone phone = session.find( Phone.class, PHONE_ID );
84+
phone.setNumber( "456" );
85+
session.flush();
86+
session.markForRollbackOnly();
87+
} );
88+
// in a different transaction
89+
scope.inTransaction( session -> {
90+
final Phone phone = session.find( Phone.class, PHONE_ID );
91+
assertThat( phone.getNumber() ).isEqualTo( "123" );
92+
} );
93+
}
94+
7895
@Entity( name = "Phone" )
7996
@Cacheable
8097
@Cache( usage = CacheConcurrencyStrategy.TRANSACTIONAL )

0 commit comments

Comments
 (0)