arnaudroger / SimpleFlatMapper

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper
http://simpleflatmapper.org
MIT License
437 stars 76 forks source link

jOOQ DTO-less one-to-many not working on jdk9 #514

Closed otamnaz closed 6 years ago

otamnaz commented 6 years ago

Using jOOQ 3.10.1

This works as expected with

But got an IllegalArgumentException when upgrading to

The Exception was thrown at JdbcMapperFactory.newInstance().addKeys("ID").newMapper(...);

FenceBoxRepo.java:

JdbcMapper<Tuple2<FenceBoxRecord, MatMasterRecord>> mapper = JdbcMapperFactory       
   .newInstance()
   .addKeys("ID")
   .newMapper(new TypeReference<Tuple2<FenceBoxRecord, MatMasterRecord>>() {});

 ResultSet rs = create.select(FENCE_BOX.ID, FENCE_BOX.CODE, FENCE_BOX.NAME, FENCE_BOX.ACTIVE,
                              MAT_MASTER.ID, MAT_MASTER.CODE, MAT_MASTER.NAME)
                         .from(FENCE_BOX)
                         .join(MAT_MASTER).on(FENCE_BOX.MAT_MASTER_ID.eq(MAT_MASTER.ID))
                         .fetchResultSet();

The exception:

java.lang.IllegalArgumentException
    at org.simpleflatmapper.ow2asm.ClassReader.<init>(ClassReader.java:170)
    at org.simpleflatmapper.ow2asm.ClassReader.<init>(ClassReader.java:153)
    at org.simpleflatmapper.ow2asm.ClassReader.<init>(ClassReader.java:424)
    at org.simpleflatmapper.reflect.asm.AsmInstantiatorDefinitionFactory.extractDefinitions(AsmInstantiatorDefinitionFactory.java:40)
    at org.simpleflatmapper.reflect.ReflectionService.extractInstantiator(ReflectionService.java:200)
    at org.simpleflatmapper.reflect.ReflectionService.extractInstantiator(ReflectionService.java:192)
    at org.simpleflatmapper.reflect.meta.TupleClassMeta.getInstantiatorDefinition(TupleClassMeta.java:67)
    at org.simpleflatmapper.reflect.meta.TupleClassMeta.<init>(TupleClassMeta.java:37)
    at org.simpleflatmapper.reflect.ReflectionService.newClassMeta(ReflectionService.java:152)
    at org.simpleflatmapper.reflect.ReflectionService.getClassMeta(ReflectionService.java:128)
    at org.simpleflatmapper.map.mapper.AbstractMapperFactory.getClassMeta(AbstractMapperFactory.java:310)
    at org.simpleflatmapper.jdbc.JdbcMapperFactory.newMapper(JdbcMapperFactory.java:247)
    at org.simpleflatmapper.jdbc.JdbcMapperFactory.newMapper(JdbcMapperFactory.java:225)
    at spali.cm.core.db.FenceBoxRepo.listAll(FenceBoxRepo.java:64)
arnaudroger commented 6 years ago

Thanks for the report will have a look asap

arnaudroger commented 6 years ago

How do you run the app? How is it build? Could you do a mvn dependency:list

arnaudroger commented 6 years ago

Ps that error is due to the asm reader not recognising the new bytecode version. So that would mean it ran against the wrong version of Sfm reflect or Sfm reflect #s the wrong asm packaged or the byte code is built with Java 11

otamnaz commented 6 years ago

Run with ./gradlew bootRun

Here's my gradle dependencies

$ ./gradlew dependencies

> Task :dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

apiElements - API elements for main. (n)
No dependencies

archives - Configuration for archive artifacts.
No dependencies

bootArchives - Configuration for Spring Boot archive artifacts.
No dependencies

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- project :jooq-custom
|    \--- org.jooq:jooq-codegen:3.10.6 -> 3.10.1
|         +--- org.jooq:jooq:3.10.1
|         \--- org.jooq:jooq-meta:3.10.1
|              \--- org.jooq:jooq:3.10.1
+--- org.scala-lang:scala-library:2.12.4
+--- org.springframework.boot:spring-boot-starter-jooq: -> 2.0.1.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.0.1.RELEASE
|    |    +--- org.springframework.boot:spring-boot:2.0.1.RELEASE
|    |    |    +--- org.springframework:spring-core:5.0.5.RELEASE
|    |    |    |    \--- org.springframework:spring-jcl:5.0.5.RELEASE
|    |    |    \--- org.springframework:spring-context:5.0.5.RELEASE
|    |    |         +--- org.springframework:spring-aop:5.0.5.RELEASE
|    |    |         |    +--- org.springframework:spring-beans:5.0.5.RELEASE
|    |    |         |    |    \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    |         |    \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    |         +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |    |         +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    |         \--- org.springframework:spring-expression:5.0.5.RELEASE
|    |    |              \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.0.1.RELEASE
|    |    |    \--- org.springframework.boot:spring-boot:2.0.1.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:2.0.1.RELEASE
|    |    |    +--- ch.qos.logback:logback-classic:1.2.3
|    |    |    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.25
|    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.10.0
|    |    |    |    +--- org.slf4j:slf4j-api:1.7.25
|    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.10.0
|    |    |    \--- org.slf4j:jul-to-slf4j:1.7.25
|    |    |         \--- org.slf4j:slf4j-api:1.7.25
|    |    +--- javax.annotation:javax.annotation-api:1.3.2
|    |    +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    \--- org.yaml:snakeyaml:1.19
|    +--- org.springframework.boot:spring-boot-starter-jdbc:2.0.1.RELEASE
|    |    +--- org.springframework.boot:spring-boot-starter:2.0.1.RELEASE (*)
|    |    +--- com.zaxxer:HikariCP:2.7.8
|    |    |    \--- org.slf4j:slf4j-api:1.7.25
|    |    \--- org.springframework:spring-jdbc:5.0.5.RELEASE
|    |         +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |         +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |         \--- org.springframework:spring-tx:5.0.5.RELEASE
|    |              +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |              \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    +--- org.springframework:spring-tx:5.0.5.RELEASE (*)
|    \--- org.jooq:jooq:3.10.6 -> 3.10.1
+--- org.springframework.boot:spring-boot-starter-web: -> 2.0.1.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.0.1.RELEASE (*)
|    +--- org.springframework.boot:spring-boot-starter-json:2.0.1.RELEASE
|    |    +--- org.springframework.boot:spring-boot-starter:2.0.1.RELEASE (*)
|    |    +--- org.springframework:spring-web:5.0.5.RELEASE
|    |    |    +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |    |    \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    +--- com.fasterxml.jackson.core:jackson-databind:2.9.5
|    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
|    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.9.5
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.5
|    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.9.5
|    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.9.5 (*)
|    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.5
|    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
|    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.9.5
|    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.9.5 (*)
|    |    \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.5
|    |         +--- com.fasterxml.jackson.core:jackson-core:2.9.5
|    |         \--- com.fasterxml.jackson.core:jackson-databind:2.9.5 (*)
|    +--- org.springframework.boot:spring-boot-starter-tomcat:2.0.1.RELEASE
|    |    +--- javax.annotation:javax.annotation-api:1.3.2
|    |    +--- org.apache.tomcat.embed:tomcat-embed-core:8.5.29
|    |    +--- org.apache.tomcat.embed:tomcat-embed-el:8.5.29
|    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:8.5.29
|    |         \--- org.apache.tomcat.embed:tomcat-embed-core:8.5.29
|    +--- org.hibernate.validator:hibernate-validator:6.0.9.Final
|    |    +--- javax.validation:validation-api:2.0.1.Final
|    |    +--- org.jboss.logging:jboss-logging:3.3.2.Final
|    |    \--- com.fasterxml:classmate:1.3.4
|    +--- org.springframework:spring-web:5.0.5.RELEASE (*)
|    \--- org.springframework:spring-webmvc:5.0.5.RELEASE
|         +--- org.springframework:spring-aop:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-context:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-expression:5.0.5.RELEASE (*)
|         \--- org.springframework:spring-web:5.0.5.RELEASE (*)
+--- org.springframework.boot:spring-boot-starter-security: -> 2.0.1.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.0.1.RELEASE (*)
|    +--- org.springframework:spring-aop:5.0.5.RELEASE (*)
|    +--- org.springframework.security:spring-security-config:5.0.4.RELEASE
|    |    +--- org.springframework.security:spring-security-core:5.0.4.RELEASE
|    |    |    +--- org.springframework:spring-aop:5.0.5.RELEASE (*)
|    |    |    +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |    |    +--- org.springframework:spring-context:5.0.5.RELEASE (*)
|    |    |    +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    |    |    \--- org.springframework:spring-expression:5.0.5.RELEASE (*)
|    |    +--- org.springframework:spring-aop:5.0.5.RELEASE (*)
|    |    +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |    +--- org.springframework:spring-context:5.0.5.RELEASE (*)
|    |    \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    \--- org.springframework.security:spring-security-web:5.0.4.RELEASE
|         +--- org.springframework.security:spring-security-core:5.0.4.RELEASE (*)
|         +--- org.springframework:spring-aop:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-context:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-expression:5.0.5.RELEASE (*)
|         \--- org.springframework:spring-web:5.0.5.RELEASE (*)
+--- io.jsonwebtoken:jjwt:0.9.0
|    \--- com.fasterxml.jackson.core:jackson-databind:2.8.9 -> 2.9.5 (*)
+--- org.springframework.security:spring-security-ldap: -> 5.0.4.RELEASE
|    +--- org.springframework.ldap:spring-ldap-core:2.3.2.RELEASE
|    |    \--- org.slf4j:slf4j-api:1.7.21 -> 1.7.25
|    +--- org.springframework.security:spring-security-core:5.0.4.RELEASE (*)
|    +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    +--- org.springframework:spring-context:5.0.5.RELEASE (*)
|    +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    \--- org.springframework:spring-tx:5.0.5.RELEASE (*)
+--- org.flywaydb:flyway-core: -> 5.0.7
+--- org.springframework.boot:spring-boot-starter-websocket: -> 2.0.1.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.0.1.RELEASE (*)
|    +--- org.springframework.boot:spring-boot-starter-web:2.0.1.RELEASE (*)
|    +--- org.springframework:spring-messaging:5.0.5.RELEASE
|    |    +--- org.springframework:spring-beans:5.0.5.RELEASE (*)
|    |    \--- org.springframework:spring-core:5.0.5.RELEASE (*)
|    \--- org.springframework:spring-websocket:5.0.5.RELEASE
|         +--- org.springframework:spring-context:5.0.5.RELEASE (*)
|         +--- org.springframework:spring-core:5.0.5.RELEASE (*)
|         \--- org.springframework:spring-web:5.0.5.RELEASE (*)
+--- org.webjars:webjars-locator-core: -> 0.35
|    +--- org.slf4j:slf4j-api:1.7.7 -> 1.7.25
|    +--- org.apache.commons:commons-lang3:3.1 -> 3.7
|    +--- org.apache.commons:commons-compress:1.9
|    \--- com.fasterxml.jackson.core:jackson-core:2.7.3 -> 2.9.5
+--- org.webjars:stomp-websocket:2.3.3
+--- org.jooq:jool:0.9.13
+--- org.simpleflatmapper:sfm-jdbc:3.17.4
|    \--- org.simpleflatmapper:sfm-map:3.17.4
|         \--- org.simpleflatmapper:sfm-reflect:3.17.4
|              +--- org.simpleflatmapper:sfm-util:3.17.4
|              \--- org.simpleflatmapper:sfm-converter:3.17.4
|                   \--- org.simpleflatmapper:sfm-util:3.17.4
+--- commons-dbcp:commons-dbcp:1.4
|    \--- commons-pool:commons-pool:1.5.4 -> 1.6
+--- org.postgresql:postgresql: -> 42.2.2
\--- org.apache.poi:poi-ooxml:3.17
     +--- org.apache.poi:poi:3.17
     |    +--- commons-codec:commons-codec:1.10 -> 1.11
     |    \--- org.apache.commons:commons-collections4:4.1
     +--- org.apache.poi:poi-ooxml-schemas:3.17
     |    \--- org.apache.xmlbeans:xmlbeans:2.6.0
     |         \--- stax:stax-api:1.0.1
     \--- com.github.virtuald:curvesapi:1.04
arnaudroger commented 6 years ago

gradle my weakness. I guess the classifier might not pass through. could you try explicitly including sfm-reflect with the jdk9 classifier.

I have a story to sort out the asm shading, the jdk8 build should include the last version of asm instead of 5.1 which would avoid those kind of issues

otamnaz commented 6 years ago

Thanks, it worked!

with:

dependencies {
  ...

  compile ('org.simpleflatmapper:sfm-jdbc:3.17.4:jdk9') {
    exclude group: "org.simpleflatmapper", module:"sfm-reflect"
  }
  compile "org.simpleflatmapper:sfm-reflect:3.17.4:jdk9"

  ...
}
arnaudroger commented 6 years ago

no ideal, I'll need to look at how that works with gradle.

arnaudroger commented 6 years ago

BTW just pushed 3.17.5 with version 6.1.1 shipped with the main build. if you update to that version you should not have to force sfm-reflect jdk9. Could you try it out?

otamnaz commented 6 years ago

Try updating to 3.17.5 without force sfm-reflect, works as expected.

arnaudroger commented 6 years ago

great, btw that also mean if you don't care about the module-info that you can use the one without the jdk9 classifier.