CodeGenerator 3.14.1 fails on Oracle Timestamp with precision

64 views
Skip to first unread message

Patrick Brunmayr

unread,
Nov 10, 2020, 8:50:40 AM11/10/20
to jOOQ User Group
Following DDL given

CREATE TABLE API_CLIENT 
(
  ID RAW(16) NOT NULL 
, API_CONSUMER_ID RAW(16) NOT NULL 
, APP_ID VARCHAR2(256 CHAR) NOT NULL 
, ACTIVE NUMBER(*, 0) DEFAULT 1 NOT NULL 
, LAST_MODIFIED TIMESTAMP(6) NOT NULL 
, PRICING_DOMAIN VARCHAR2(256 CHAR) NOT NULL 
, TRUSTED NUMBER(*, 0) DEFAULT 0 NOT NULL 
, NAME VARCHAR2(128 CHAR) 
, CREATED TIMESTAMP(6) NOT NULL 

will create this field in the Table

public final TableField<ApiClientRecord, LocalDateTime> CREATED = createField(DSL.name("CREATED"), SQLDataType.LOCALDATETIME(6).nullable(false), this, "");

which leads to error

error: cannot find symbol
    public final TableField<ApiClientRecord, LocalDateTime> LAST_MODIFIED = createField(DSL.name("LAST_MODIFIED"), SQLDataType.LOCALDATETIME(6).nullable(false), this, "");
                                                                                                                              ^
  symbol:   method LOCALDATETIME(int)
  location: class SQLDataType

It seems there is no matching constructor with a precision. How to fix this?

Patrick Brunmayr

unread,
Nov 10, 2020, 8:58:12 AM11/10/20
to jOOQ User Group
So it seems it got fixed in 3.14.3 ?

Lukas Eder

unread,
Nov 10, 2020, 9:02:49 AM11/10/20
to jOOQ User Group
Hi Patrick,

Thanks for your message.

There hasn't been any such fix in jOOQ 3.14.3. But I don't think we have such a problem, currently. The most likely reason why you're seeing this kind of compilation error is because you're generating code with jOOQ version X and trying to compile it with an older jOOQ version Y. This can happen, for example, due to a transitive dependency that you might be using via Spring Boot or some other framework. If you're using Maven, please check "mvn dependency:tree" to see the jOOQ version, see also:

Thanks,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/58b1849d-a83f-4e05-baba-6ab0b550430an%40googlegroups.com.

Patrick Brunmayr

unread,
Nov 10, 2020, 9:07:08 AM11/10/20
to jOOQ User Group
I downloaded the enterprise version, installed it in my local maven and tried to use it from gradle script so there is no other dependency

Lukas Eder

unread,
Nov 10, 2020, 9:10:12 AM11/10/20
to jOOQ User Group
Can you show the gradle script?

Patrick Brunmayr

unread,
Nov 10, 2020, 9:10:15 AM11/10/20
to jOOQ User Group
When i run it i get this

cvc-complex-type.2.4.a: Ung�ltiger Content wurde beginnend mit Element '{"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":primaryKeyTypes}' gefunden. '{"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":generatedAnnotationDate, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":constructorPropertiesAnnotation, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":constructorPropertiesAnnotationOnPojos, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":constructorPropertiesAnnotationOnRecords, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":pojosAsJavaRecordClasses, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":pojosAsScalaCaseClasses, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":pojosAsKotlinDataClasses, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":jpaVersion, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":globalDomainReferences, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":commentsOnEmbeddables, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":generatedSerialVersionUID, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":maxMembersPerInitialiser, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":newline, "http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":indentation}' wird erwartet.

i added this

configurations['classpath'].resolutionStrategy.eachDependency {
if (requested.group == 'org.jooq') {
useVersion '3.14.1'
}
}

Patrick Brunmayr

unread,
Nov 10, 2020, 9:13:37 AM11/10/20
to jOOQ User Group
jooqGenerator - The classpath used to invoke the jOOQ code generator. Add your JDBC driver, generator extensions, and additional dependencies here.
+--- org.jooq:jooq-codegen -> org.jooq.pro:jooq-codegen:3.14.1
|    +--- org.jooq.pro:jooq:3.14.1
|    |    +--- org.reactivestreams:reactive-streams:1.0.2 -> 1.0.3
|    |    \--- javax.xml.bind:jaxb-api:2.3.1
|    |         \--- javax.activation:javax.activation-api:1.2.0
|    \--- org.jooq.pro:jooq-meta:3.14.1
|         \--- org.jooq.pro:jooq:3.14.1 (*)

Patrick Brunmayr

unread,
Nov 10, 2020, 9:17:18 AM11/10/20
to jOOQ User Group
The gradle configuration

jooq {
  version = project.ext.get('jooq.version')
  configurations {
    main { // name of the jOOQ configuration
      generateSchemaSourceOnCompilation = true // default (can be omitted)

      generationTool {
        logging = org.jooq.meta.jaxb.Logging.WARN
        jdbc {
          driver = 'oracle.jdbc.driver.OracleDriver'
          url = 'jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=atlogoracletest.pbs.local)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PRBPDE.db.logitek.at)))'
          user = 'PRICING_BPDE'
          password = 'PRICING_BPDE'
        }
        generator {
          name = 'org.jooq.codegen.DefaultGenerator'
          database {
            name = 'org.jooq.meta.oracle.OracleDatabase'
            inputSchema = 'PRICING_BPDE'
            outputSchemaToDefault = true
            includes = ['API_CLIENT', 'API_CLIENT_PRICE_TYPE', 'API_CLIENT_SCOPE', 'API_CONSUMER', 'API_SCOPE', 'CUSTOMER', 'CUSTOMER_ACE', 'CUSTOMER_PRICE_CONTAINER', 'CUSTOMER_PRICE_CONTAINER_ACE', 'CUSTOMER_PRICE_CONTAINER_URN', 'CUSTOMER_URN', 'DEALER', 'DEALER_ACE', 'DEALER_PRODUCT_CATALOG', 'DEALER_PRODUCT_CATALOG_ACE', 'DEALER_PRODUCT_CATALOG_URN', 'DEALER_URN', 'PRICE', 'PRICE_CALCULATION_TYPE', 'PRICE_CONTAINER', 'PRICE_CONTAINER_ACE', 'PRICE_CONTAINER_URN', 'PRICE_TYPE', 'PRICE_TYPE_URN', 'PRICE_URN', 'PRODUCT', 'PRODUCT_ACE', 'PRODUCT_CATALOG', 'PRODUCT_CATALOG_ACE', 'PRODUCT_CATALOG_PRODUCT', 'PRODUCT_CATALOG_PRODUCT_URN', 'PRODUCT_CATALOG_URN', 'PRODUCT_URN'].join("|")
          }
          generate {
            deprecated = false
            records = true
            immutablePojos = false
            fluentSetters = false
          }
          target {
            packageName = 'at.logitek.pricing.model.core.persistence.jooq'
            directory = 'build/generated-src/jooq/main' // default (can be omitted)
          }
          strategy.name = 'org.jooq.codegen.DefaultGeneratorStrategy'
        }
      }
    }
  }
}

Patrick Brunmayr

unread,
Nov 10, 2020, 9:30:45 AM11/10/20
to jOOQ User Group
It seems its related to this plugin. Works with 3.13.5

Lukas Eder

unread,
Nov 10, 2020, 9:34:16 AM11/10/20
to jOOQ User Group
Thanks for your update. That looks correct as far as the code generation is concerned. But how do you compile the generated output?

Patrick Brunmayr

unread,
Nov 10, 2020, 9:55:25 AM11/10/20
to jOOQ User Group
I just copy the generated sources into a project folder. Then when i wanted to compile it got those errors. 

Maybe a future version of this plugin will handle a newer jooq version?

Lukas Eder

unread,
Nov 10, 2020, 10:00:58 AM11/10/20
to jOOQ User Group
From what I can tell from their documentation, there are two versions that you can specify. The one you specified affects only code generation (I think?)


So, this one:
version = project.ext.get('jooq.version')  

Patrick Brunmayr

unread,
Nov 10, 2020, 10:26:48 AM11/10/20
to jOOQ User Group
Yeah the  v5.2  is the plugin version. In their release they wrote ->  Upgrades to jOOQ 3.13.5   

I tried exactly this

version = project.ext.get('jooq.version')  // '3.14.1

but i think there is an issue with xml code generation. It complains the xml is not valid. Then i did

configurations['classpath'].resolutionStrategy.eachDependency {
if (requested.group == 'org.jooq') {
useVersion '3.14.1'
}
} 

Then the generation works but it generates the wrong java code. 

When i am using 3.15.3 without anything it works like a charme

Lukas Eder

unread,
Nov 11, 2020, 7:55:54 AM11/11/20
to jOOQ User Group
I've had another go at trying this myself, and I could reproduce the XSD errors that you've seen. The third party plugin can load the JAXB classes from different jOOQ versions to map the Groovy/Kotlin configuration to. You seem to have been on the right track with your useVersion directive, which I believe you've taken from here?

I don't know what may have gone wrong with version 3.14.1, but when I tried this with 3.14.3, things seem to work for me:

buildscript {
    configurations['classpath'].resolutionStrategy.eachDependency {
if (requested.group == 'org.jooq') {
            useVersion '3.14.3'
}
}
}

plugins {
id 'nu.studer.jooq' version '5.2'
id 'java'
}

repositories {
jcenter()
mavenLocal()
}

dependencies {
jooqGenerator 'com.h2database:h2:1.4.200'
}

jooq {
version = '3.14.3'
edition = nu.studer.gradle.jooq.JooqEdition.TRIAL_JAVA_8

configurations {
main {
            generationTool {
logging = org.jooq.meta.jaxb.Logging.WARN
jdbc {
                    driver = 'org.h2.Driver'
url = 'jdbc:h2:~/jooq-test-codegen-gradle;AUTO_SERVER=TRUE'
user = 'sa'
password = ''
}
generator {
database {
name = 'org.jooq.meta.h2.H2Database'
includes = '.*'
excludes = ''
}
target {
packageName = 'nu.studer.sample'
}
}
}
}
}
}

Reply all
Reply to author
Forward
0 new messages