jklingsporn / vertx-jooq

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

UDT pojos and records have not implemented toJson and fromJson methods #130

Closed shivamsriva31093 closed 4 years ago

shivamsriva31093 commented 4 years ago

I am using the latest release (5.0.1) to programmatically generate the schema classes. Everything is generated perfectly except the records and pojos of the user-defined types. All the generated classes in these packages are missing the implementation of toJson and fromJson methods, as they extend the VertxPojo interface.

I have followed the example in AbstractDatabaseConfigurationProvider as suggested by the documentation of vertx-jooq-rx-reactive. I tried looking for similar issues on GitHub and SO but had no luck.

Following is the generate config:

` /*

Error during compilation: Class 'TypeTlmyAccRecord' must either be declared abstract or implement abstract method 'fromJson(JsonObject)' in 'VertxPojo

Vertx version: 3.8.5 Java version: 1.8.191 IDE: IntelliJ IDEA Build Tool: mvn vertx-jooq: 5.0.1 jooq: 3.12.3

jklingsporn commented 4 years ago

Everything is generated perfectly except the records and pojos of the user-defined types.

Are there any warnings/error during code generation? Have you tried code generation using maven?

shivamsriva31093 commented 4 years ago

No there are no errors during generation. I have not tried with Maven as the connection strings are dynamic based on a tenant id. But I will give it a try and let you know. Thank you.

shivamsriva31093 commented 4 years ago

Hi @jklingsporn I tried generating using maven. Getting same result. There are no errors as well.

jklingsporn commented 4 years ago

Can you please try with the latest release (5.1.0) and also set the <onError>LOG</onError> or <onError>FAIL</onError> in the configuration (https://www.jooq.org/doc/3.13/manual/code-generation/codegen-advanced/codegen-config-onerror/)

crackzko commented 4 years ago

Hi, @jklingsporn thanks for your great work! I have the same problem and did as you suggested updated to 5.1.0 and jooq 3.13.1. I set onError= 'LOG' but the generation goes through without an error thrown so there is nothing in the log about it. I have still the same result. The VertxPojo interface is not implemented by Pojos and Records.

Vertx version: 3.8.5 Java version: 11 IDE: IntelliJ IDEA Build Tool: gradle vertx-jooq: 5.1.0 jooq: 3.13.1

jklingsporn commented 4 years ago

Have you tried setting it to FAIL? For me the logging configuration does not seem to work all the time.

Having said that, while upgrading at work, the generation failed too. After fixing the logging, I saw that there were problems generating case sensitive enum values with postgres (jooq bug). After changing them to snake case it worked.

crackzko notifications@github.com schrieb am So., 8. März 2020, 02:51:

Hi, @jklingsporn https://github.com/jklingsporn thanks for your great work! I have the same problem and did as you suggested updated to 5.1.0 and jooq 3.13.1. I set onError= 'LOG' but the generation goes through without an error thrown so there is nothing in the log about it. I have still the same result. The VertxPojo interface is not implemented by Pojos and Records.

Vertx version: 3.8.5 Java version: 11 IDE: IntelliJ IDEA Build Tool: gradle vertx-jooq: 5.1.0 jooq: 3.13.1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jklingsporn/vertx-jooq/issues/130?email_source=notifications&email_token=ABQLZXUFSB2W5VJZEDEYKHTRGL2ZZA5CNFSM4KZUFRBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOEKEAA#issuecomment-596156928, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQLZXWGZYEVBC55ZFX2JYDRGL2ZZANCNFSM4KZUFRBA .

crackzko commented 4 years ago

Thanks for the fast reply, I tried setting it to FAIL and tried it on a little test database with only one table with three columns and no relations and so.

VertxPojo is implemented but there are no overrides for

My Generator Configuration looks like:

jooq {
    version = '3.13.1'
    edition = 'OSS'
    generateSchemaSourceOnCompilation = true
    sample(sourceSets.main) {
        onError = 'FAIL'
        jdbc {
            driver = 'com.mysql.cj.jdbc.Driver'
            url = 'jdbc:mysql://localhost:3306'
            user = 'test'
            password = 'ultimateSecretTestPassword1'
        }
        generator {
            name = 'org.jooq.codegen.DefaultGenerator'
            database {
                name = 'org.jooq.meta.mysql.MySQLDatabase'
                includes = 'test.*'
            }
            generate {
                relations = true
                deprecated = false
                records = true
                immutablePojos = true
                fluentSetters = true
            }
            target() {
                packageName = 'test.persistence.mysql.sql'
                directory = "$projectDir/src/main/java"
            }
            strategy {
                name = 'io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy'
            }
        }
    }
}

And my Test DB:

CREATE DATABASE IF NOT EXISTS `test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `test`;

-- Exportiere Struktur von Tabelle test.platforms
CREATE TABLE IF NOT EXISTS `platforms` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(45) COLLATE utf8_bin NOT NULL,
  `external_id` mediumint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`),
  UNIQUE KEY `external_id_UNIQUE` (`external_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

MySQL Version: 8.0.19 - MySQL Community Server - GPL OS : Windows 10

shivamsriva31093 commented 4 years ago

Can you please try with the latest release (5.1.0) and also set the <onError>LOG</onError> or <onError>FAIL</onError> in the configuration (https://www.jooq.org/doc/3.13/manual/code-generation/codegen-advanced/codegen-config-onerror/)

Hi @jklingsporn , I tried using both maven and java, there are no errors logged.

jklingsporn commented 4 years ago

@crackzko could you please replace the generator org.jooq.codegen.DefaultGenerator with a proper vertx-jooq variant, e.g. io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator I tried your schema and it generated the classes properly.

jklingsporn commented 4 years ago

Can you please try with the latest release (5.1.0) and also set the <onError>LOG</onError> or <onError>FAIL</onError> in the configuration (https://www.jooq.org/doc/3.13/manual/code-generation/codegen-advanced/codegen-config-onerror/)

Hi @jklingsporn , I tried using both maven and java, there are no errors logged.

Do you see any logs at all? If not, make sure to set the jooq-LogLevel and/or the log level your log configration file.

crackzko commented 4 years ago

@crackzko could you please replace the generator org.jooq.codegen.DefaultGenerator with a proper vertx-jooq variant, e.g. io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator I tried your schema and it generated the classes properly.

This works totally fine for me, thanks! <3 It seems i totally messed up.