admin管理员组

文章数量:1290935

It's not documented here /

It only shows you that an uncaught exception will cause a rollback.

The problem is that RollbackToSavepointStep is not a Publisher.

Is it possible to programmatically rollback at all?

If I try dsl().rollback().executeAsync().await() then I get:

DetachedException: Attempt to execute a blocking method (e.g. Query.execute() or ResultQuery.fetch()) when only an R2BDC ConnectionFactory was configured. jOOQ's RowCountQuery and ResultQuery extend Publisher, which allows for reactive streams implementations to subscribe to the results of a jOOQ query. Simply embed your query in the stream, e.g. using Flux.from(query). See also: /

It's not documented here https://www.jooq./doc/latest/manual/sql-execution/transaction-management/

It only shows you that an uncaught exception will cause a rollback.

The problem is that RollbackToSavepointStep is not a Publisher.

Is it possible to programmatically rollback at all?

If I try dsl().rollback().executeAsync().await() then I get:

DetachedException: Attempt to execute a blocking method (e.g. Query.execute() or ResultQuery.fetch()) when only an R2BDC ConnectionFactory was configured. jOOQ's RowCountQuery and ResultQuery extend Publisher, which allows for reactive streams implementations to subscribe to the results of a jOOQ query. Simply embed your query in the stream, e.g. using Flux.from(query). See also: https://www.jooq./doc/latest/manual/sql-execution/fetching/reactive-fetching/
Share Improve this question asked Feb 13 at 15:35 Jakub BochenskiJakub Bochenski 3,2774 gold badges38 silver badges67 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You can use the ROLLBACK statement and execute that reactively. Just not with executeAsync(), which currently doesn't have any R2DBC backed implementation as the exception states. There's a feature request for this as of jOOQ 3.19:

  • https://github/jOOQ/jOOQ/issues/15907

Instead, you should be able to just write:

dsl().rollback().awaitSingle()

Note, this currently doesn't work because of this bug in jOOQ 3.19.18 and earlier:

  • https://github/jOOQ/jOOQ/issues/18014

The Rollback type extends only Query, not RowCountQuery, which is a Publisher<Integer>. Given that this is just a matter of wrong API specification, do this, instead, as a workaround:

(dsl().rollback() as RowCountQuery).awaitSingle()

本文标签: kotlin coroutinesHow to programmatically rollback transaction using Jooq Non blocking APIStack Overflow