Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,12 @@ public CompletionStage<Integer> reactiveExecute(JdbcParameterBindings jdbcParame

private CompletionStage<Void> deleteRows(JdbcParameterBindings jdbcParameterBindings, StandardReactiveJdbcMutationExecutor jdbcMutationExecutor, SqmJdbcExecutionContextAdapter executionContext, int[] rows) {
if ( getEntityDescriptor() instanceof UnionSubclassEntityPersister ) {
return CompletionStages
.loop( getDeletes(), delete -> reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
return loop( getDeletes(), delete -> reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
.thenApply( tot -> rows[0] += tot )
);
}
else {
return CompletionStages
.loop( getDeletes(), delete -> reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
return loop( getDeletes(), delete -> reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
.thenApply( tot -> rows[0] = tot )
);
}
Expand All @@ -128,8 +126,10 @@ private CompletionStage<Integer> executeDelete(
);
}
return loop( getCollectionTableDeletes(), delete ->
reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
).thenApply( v -> rows );
reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
).thenCompose( v -> loop( getDeletes(), delete ->
reactiveExecute( jdbcParameterBindings, delete, jdbcMutationExecutor, executionContext )
) ).thenApply( v -> rows );
}

private static CompletionStage<Integer> reactiveExecute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,29 @@ public void testHqlInsertWithTransaction(VertxTestContext context) {
);
}

@Test
public void testHqlDelete(VertxTestContext context) {
final Integer id = 1;
final String title = "Spell Book: A Comprehensive Guide to Magic Spells and Incantations";
SpellBook spellBook = new SpellBook( id, title, true, new Date() );
test( context, getMutinySessionFactory().withTransaction( session -> session.persist( spellBook ) )
.call( () -> getMutinySessionFactory().withTransaction( session -> session
.createMutationQuery(
"delete from SpellBook where id = :id and forbidden = :forbidden and title = :title" )
.setParameter( "id", id )
.setParameter( "title", title )
.setParameter( "forbidden", true )
.executeUpdate() )
)
.call( () -> getMutinySessionFactory().withTransaction( session -> session
.createSelectionQuery( "from SpellBook g where g.id = :id ", SpellBook.class )
.setParameter( "id", id )
.getSingleResultOrNull()
.invoke( Assertions::assertNull ) )
)
);
}

@Entity(name="SpellBook")
@Table(name = "SpellBookJS")
@DiscriminatorValue("S")
Expand Down
Loading