-
[CONTEXT] // repositories
@R2dbcRepository(dialect = MYSQL)
interface EmployeeRepository :
CoroutineCrudRepository<Employee, Long>,
CoroutineJpaSpecificationExecutor<Employee> {
@Transactional(propagation = TransactionDefinition.Propagation.MANDATORY)
override suspend fun <S : Employee> save(entity: S): S
}
@R2dbcRepository(dialect = MYSQL)
interface ExternalEmployeeRepository :
CoroutineCrudRepository<ExternalEmployee, ExternalEmployeeId>,
CoroutineJpaSpecificationExecutor<ExternalEmployee> {
@Transactional(propagation = TransactionDefinition.Propagation.MANDATORY)
override suspend fun <S : ExternalEmployee> save(entity: S): S
}
// service
@Singleton
open class CreateEmployeeUseCase(
private val createEmployeeService: CreateEmployeeService, // inject EmployeeRepository and save data
private val createExternalEmployeeService: CreateExternalEmployeeService // inject ExternalEmployeeRepository and save data
) : CreateEmployeePort {
@Transactional
override suspend fun create(employee: Employee) =
createEmployeeService.create(employee)
.also { createExternalEmployeeService.create(it) }
} flyway:
datasources:
default:
enabled: true
baseline-on-migrate: true
datasources:
default:
dialect: MYSQL
driverClassName: com.mysql.cj.jdbc.Driver
schema-generate: NONE
url: jdbc:mysql://localhost:3306/txwithr2dbc
username: root
password: root
db-type: mysql
r2dbc:
datasources:
default:
schema-generate: NONE
url: r2dbc:mysql://localhost:3306/txwithr2dbc
username: root
password: root
dialect: MYSQL
driver: mysql
db-type: mysql [ERROR]
OK, it's understandable because Hikari is using a JDBC connection as the initial log points out...
[SOLUTIONS]
[QUESTION] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hikari is a JDBC pool, R2DBC is a completely different technology. |
Beta Was this translation helpful? Give feedback.
Hikari is a JDBC pool, R2DBC is a completely different technology.
If I understand correctly you only want to use flyway for the migration, in this case, you don't need a JDBC pool. And I would recommend you keep R2DBC as
default
and rename the JDBC configuration to something likemigration
.