jklingsporn / vertx-jooq

A jOOQ-CodeGenerator to create vertx-ified DAOs and POJOs.
MIT License
385 stars 53 forks source link

fix(reactive): Fix ClassCastException with the reactive database driver. #138

Closed vmaubert closed 4 years ago

vmaubert commented 4 years ago

Hi, With the new reactive pg database driver, I can't begin a transaction. I wanted to write a test but I didn't find any test in this module.

jklingsporn commented 4 years ago

Hi, thank you for your PR. The according test is located in io.github.jklingsporn.vertx.jooq.generate.classic.reactive.regular.SomethingDaoTest. I think it all boils down to the question what implementation of the SqlClient you are adding to the QueryExecutor. The test uses a PgPool for that matter. I was not aware about the SqlConnection which for some reason also extends SqlClient but has a synchronous method signature for the transaction-method. So for now I cannot merge until I fully understand both usecases.

jklingsporn commented 4 years ago

I read the docs here at https://vertx.io/docs/vertx-pg-client/java/#_using_transactions I do understand that you can start transactions directly on a SqlConnection but it don't think you should instantiate a DAO/QueryExecutor with a SqlConnection but using a PgPool instead. Can you tell me more about your usecase?

vmaubert commented 4 years ago

Thank you for your quick review. We can create directly a DAO with a PgPool!! 🎉 😆 I didn't know that, it's cleaner than this Kotlin piece:: pgPool.getConnection({ connection -> MyDao(DefaultConfiguration(), connection})

Thank you very much.

Can we use a better type than "io.vertx.sqlclient.SqlClient" in the Dao constructor? It would be easier to find directly the "good way" to instantiate it for the beginners.