asyncer-io / r2dbc-mysql

Reactive Relational Database Connectivity for MySQL. The official successor to mirromutth/r2dbc-mysql(dev.miku:r2dbc-mysql).
https://r2dbc.io
Apache License 2.0
195 stars 21 forks source link

[QUESTION] How to begin transaction, use 0.9.3 r2dbc-mysql #137

Closed theWangs closed 1 year ago

theWangs commented 1 year ago

jdk 1.8 springboot 2.7.14 r2dbc-mysql 0.9.3 follow example: image and error mes: Cannot resolve method 'then' in 'Publisher' now ,how can i begin a transcation?

theWangs commented 1 year ago

image image miss commit so, please tell me how to do it.... This is my first time use reactor java

jchrys commented 1 year ago

Hello, @theWangs. Thank you for the question!

In the first screenshot, when you invoke the line connection.beginTransaction().then(Something), it is valid when connection.beginTransaction() returns a Mono<?> type.

There are various ways to achieve this, but a simple method is to use MySqlConnection connection = (MySqlConnection) conMono.block() instead of Connection connection = conMono.block()

If you have any further questions, please feel free to ask.

theWangs commented 1 year ago

Thanks a lot! this has been confusing me for days