jklingsporn / vertx-jooq

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

MariaDB support for lastInsertId #173

Closed leavestylecode closed 3 years ago

leavestylecode commented 3 years ago

change to classic-reactive, call dao.insertReturningPrimary(obj) will throw UnsupportedOperationException().

I'm confused for that.

屏幕快照 2021-01-06 下午3 03 51 屏幕快照 2021-01-06 下午3 05 18
jklingsporn commented 3 years ago

Hello, can you please tell me more about your configuration? The method should be overridden by the code generator in the actual DAO-implementations (see this generated DAO from the tests). However this only happens if the configured dialect for code generation is Mysql. This is the relevant part in the code generator:

if (schema.getDatabase().getDialect().family().equals(SQLDialect.MYSQL)) {
                    out.println();
                    out.tab(1).override();
                    out.tab(1).println("protected java.util.function.Function<io.vertx.sqlclient.RowSet<io.vertx.sqlclient.Row>,Long> extractMysqlLastInsertProperty(){");
                    out.tab(2).println("return rs -> rs.property(io.vertx.mysqlclient.MySQLClient.LAST_INSERTED_ID);");
                    out.tab(1).println("}");
                }
leavestylecode commented 3 years ago

My db is mariadb, so how can I fix that?

jklingsporn commented 3 years ago

For now you would need to fork the generate-module and change the VertxGeneratorBuilder like this:

if (schema.getDatabase().getDialect().family().equals(SQLDialect.MYSQL) || schema.getDatabase().getDialect().family().equals(SQLDialect.MARIADB)) {
                    out.println();
                    out.tab(1).override();
                    out.tab(1).println("protected java.util.function.Function<io.vertx.sqlclient.RowSet<io.vertx.sqlclient.Row>,Long> extractMysqlLastInsertProperty(){");
                    out.tab(2).println("return rs -> rs.property(io.vertx.mysqlclient.MySQLClient.LAST_INSERTED_ID);");
                    out.tab(1).println("}");
                }

Or wait until I've implemented it.

leavestylecode commented 3 years ago

I can wait 6.1.0 to use that😁

jklingsporn commented 3 years ago

Should be available on maven central. Please let me know if it works for you.

leavestylecode commented 3 years ago

Nice, It worked. 👏👏👏

leavestylecode commented 3 years ago

When will 6.1.0 be released ? Handsome man 😅

jklingsporn commented 3 years ago

Should be available at maven central.

leavestyle notifications@github.com schrieb am Do., 7. Jan. 2021, 07:30:

When will 6.1.0 be released ? Handsome man 😅

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jklingsporn/vertx-jooq/issues/173#issuecomment-755915856, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQLZXW4EVXQXCIECTJUBF3SYVIGTANCNFSM4VXCIQEQ .