Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Transaction does not work in MySQL environment #250

Open
pjy1368 opened this issue Feb 2, 2023 · 2 comments
Open

Transaction does not work in MySQL environment #250

pjy1368 opened this issue Feb 2, 2023 · 2 comments

Comments

@pjy1368
Copy link

pjy1368 commented Feb 2, 2023

The configuration file was created as follows.

package com.jvmhater.moduticket.configuration

import io.r2dbc.spi.ConnectionFactories
import io.r2dbc.spi.ConnectionFactory
import io.r2dbc.spi.ConnectionFactoryOptions
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.env.Environment
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories
import org.springframework.r2dbc.connection.R2dbcTransactionManager
import org.springframework.transaction.ReactiveTransactionManager

@Configuration
@EnableR2dbcRepositories
class MySQLConfiguration(private val env: Environment) : AbstractR2dbcConfiguration() {

    @Bean
    override fun connectionFactory(): ConnectionFactory {
        return ConnectionFactories.get(
            ConnectionFactoryOptions.builder()
                // ... etc connection info
                .build()
        )
    }

    @Bean
    fun transactionManager(connectionFactory: ConnectionFactory): ReactiveTransactionManager {
        return R2dbcTransactionManager(connectionFactory)
    }
}

And @transactional was added at the service layer to implement declarative transactions.

...
@Transactional(readOnly = true)
suspend fun find(id: String): Coupon {
    return couponRepository.find(id)
}
...

However, if i actually execute the above logic, an error occurs.

Receiver class dev.miku.r2dbc.mysql.MySqlConnection does not define or inherit an implementation of the resolved method 'abstract org.reactivestreams.Publisher beginTransaction(io.r2dbc.spi.TransactionDefinition)' 

I also created the ReactiveTransactionManager Bean, but why is this error occurring?

@pjy1368 pjy1368 changed the title Receiver class dev.miku.r2dbc.mysql.MySqlConnection does not define or inherit an implementation of the resolved method 'abstract org.reactivestreams.Publisher beginTransaction(io.r2dbc.spi.TransactionDefinition)' Transaction does not work in MySQL environment Feb 2, 2023
@pjy1368 pjy1368 closed this as completed Feb 3, 2023
@pjy1368 pjy1368 reopened this Feb 6, 2023
@pjy1368
Copy link
Author

pjy1368 commented Feb 6, 2023

image

When I analyzed the library, MySqlConnection did not overwrite the required method, resulting in a compilation error. What is the problem?

@jchrys
Copy link

jchrys commented Mar 21, 2023

Which version of r2dbc-spi are you using?

could you try to replace dev.miku.r2dbc-mysql with io.asyncer:r2dbc-mysql:0.9.1 and see if error is still there?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants