Skip to content

Commit bb68db8

Browse files
blafondDavideD
authored andcommitted
[#1379] test to verify fix via AbstractReactiveSaveEventListener.reactivePerformSave()
Signed-off-by: blafond <blafond@redhat.com>
1 parent 9741e1d commit bb68db8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,25 @@ private void assertThatPigsAreEqual(TestContext context, GuineaPig expected, Gui
618618
context.assertEquals( expected.getName(), actual.getName() );
619619
}
620620

621+
@Test
622+
public void testForceFlushWithDelete(TestContext context) {
623+
final GuineaPig pig1 = new GuineaPig( 111, "Aloi" );
624+
final GuineaPig pig2 = new GuineaPig( 111, "Bloi" );
625+
626+
test( context, getMutinySessionFactory()
627+
.withTransaction( session -> session
628+
.persist( pig1 )
629+
// remove pig1
630+
.call( () -> session.remove( pig1 ) )
631+
// persist pig2 with same ID as original pig1 to verify that reactive flush was performed
632+
.call( () -> session.persist( pig2 ) )
633+
).chain( () -> getMutinySessionFactory()
634+
.withSession( s -> s.find( GuineaPig.class, pig2.getId() ) ) )
635+
// check that found entity is "pig2"
636+
.invoke( result -> assertThatPigsAreEqual( context, pig2, result ) )
637+
);
638+
}
639+
621640
@Entity(name="GuineaPig")
622641
@Table(name="Pig")
623642
public static class GuineaPig {

0 commit comments

Comments
 (0)