-
-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Labels
bugSomething isn't workingSomething isn't working
Description
It happens when the method shouldFlush returns true in NativeQueryImpl#preapareForExecution:
@Override
protected void prepareForExecution() {
final var spaces = getSynchronizedQuerySpaces();
if ( spaces == null || spaces.isEmpty() ) {
// We need to flush. The query itself is not required to execute in a
// transaction; if there is no transaction, the flush would throw a
// TransactionRequiredException which would potentially break existing
// apps, so we only do the flush if a transaction is in progress.
if ( shouldFlush() ) {
getSession().flush();
}
// Reset the callback before every execution
callback = null;
}
// Otherwise, the application specified query spaces via the Hibernate
// SynchronizeableQuery and so the query will already perform a partial
// flush according to the defined query spaces - no need for a full flush.
}Testcase:
@Test
public void shouldBeAbleToRunQueryWithMutinyTransactionAndFlush(VertxTestContext context) {
test( context, getMutinySessionFactory()
.withTransaction( s -> {
s.setFlushMode( FlushMode.ALWAYS );
return s
.createNativeQuery( "select 42", Long.class ).getSingleResult()
.call( s::flush );
} ).invoke( result -> assertThat( result ).isEqualTo( 42L ) )
);
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working