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
440 stars 76 forks source link

Issue with List of Jool Tuples #488

Closed juliendangers closed 6 years ago

juliendangers commented 6 years ago

I'm trying to map some resultsets to different structures using Jool Tuples and Kotlin List (I'm not using Kotlin Pair and Triple because there is another issue with it, I'll open one after a deeper investigation)

Works:

Doesn't work:

I get the following error when it fails:

java.lang.ArrayIndexOutOfBoundsException: 1
    at org.simpleflatmapper.reflect.asm.AsmUtils.toGenericType(AsmUtils.java:274)
    at org.simpleflatmapper.reflect.asm.AsmInstantiatorDefinitionFactory$1$1.createParameter(AsmInstantiatorDefinitionFactory.java:151)
    at org.simpleflatmapper.reflect.asm.AsmInstantiatorDefinitionFactory$1$1.visitEnd(AsmInstantiatorDefinitionFactory.java:120)
    at org.simpleflatmapper.ow2asm.ClassReader.readMethod(ClassReader.java:1021)
    at org.simpleflatmapper.ow2asm.ClassReader.accept(ClassReader.java:693)
    at org.simpleflatmapper.ow2asm.ClassReader.accept(ClassReader.java:506)
    at org.simpleflatmapper.reflect.asm.AsmInstantiatorDefinitionFactory.extractDefinitions(AsmInstantiatorDefinitionFactory.java:41)
    at org.simpleflatmapper.reflect.ReflectionService.extractInstantiator(ReflectionService.java:194)
    at org.simpleflatmapper.reflect.ReflectionService.extractInstantiator(ReflectionService.java:186)
    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:146)
    at org.simpleflatmapper.reflect.ReflectionService.getClassMeta(ReflectionService.java:128)
    at org.simpleflatmapper.reflect.meta.TuplePropertyFinder.newIndexedElement(TuplePropertyFinder.java:23)
    at org.simpleflatmapper.reflect.meta.TuplePropertyFinder.access$000(TuplePropertyFinder.java:8)
    at org.simpleflatmapper.reflect.meta.TuplePropertyFinder$1.accept(TuplePropertyFinder.java:17)
    at org.simpleflatmapper.reflect.meta.TuplePropertyFinder$1.accept(TuplePropertyFinder.java:14)
    at org.simpleflatmapper.reflect.meta.TupleClassMeta.forEachProperties(TupleClassMeta.java:137)
    at org.simpleflatmapper.reflect.meta.TuplePropertyFinder.<init>(TuplePropertyFinder.java:14)
    at org.simpleflatmapper.reflect.meta.TupleClassMeta.newPropertyFinder(TupleClassMeta.java:112)
    at org.simpleflatmapper.reflect.meta.ArrayPropertyFinder.extrapolateIndex(ArrayPropertyFinder.java:49)
    at org.simpleflatmapper.reflect.meta.AbstractIndexPropertyFinder.lookForProperties(AbstractIndexPropertyFinder.java:34)
    at org.simpleflatmapper.reflect.meta.TuplePropertyFinder.extrapolateIndex(TuplePropertyFinder.java:43)
    at org.simpleflatmapper.reflect.meta.AbstractIndexPropertyFinder.lookForProperties(AbstractIndexPropertyFinder.java:34)
    at org.simpleflatmapper.reflect.meta.PropertyFinder.findProperty(PropertyFinder.java:28)
    at org.simpleflatmapper.map.mapper.PropertyMappingsBuilder._addProperty(PropertyMappingsBuilder.java:95)
    at org.simpleflatmapper.map.mapper.PropertyMappingsBuilder.addProperty(PropertyMappingsBuilder.java:73)
    at org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder.addMapping(ConstantSourceMapperBuilder.java:109)
    at org.simpleflatmapper.map.mapper.AbstractMapperBuilder.addMapping(AbstractMapperBuilder.java:171)
    at org.simpleflatmapper.jdbc.JdbcMapperFactory$SetRowMapperFactory.newInstance(JdbcMapperFactory.java:310)
    at org.simpleflatmapper.jdbc.JdbcMapperFactory$SetRowMapperFactory.newInstance(JdbcMapperFactory.java:298)
    at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.getMapper(DynamicSetRowMapper.java:101)
    at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.getMapperFromSet(DynamicSetRowMapper.java:91)
    at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.stream(DynamicSetRowMapper.java:74)
    at org.simpleflatmapper.jdbc.JdbcMapperFactory$DynamicJdbcSetRowMapper.stream(JdbcMapperFactory.java:251)

Here is the value of the target variable when it crashes:

ParameterizedTypeImpl{rawType=class org.jooq.lambda.tuple.Tuple3, types=[null]}

I will provide a full test repo to reproduce the error, but is it supposed to work with List of Tuples ?

arnaudroger commented 6 years ago

will have a look, thanks for the report.

juliendangers commented 6 years ago

Here is a repository with a spring-boot 2 project, to reproduce the issue: https://github.com/juliendangers/jooq-simpleflatmapper-issues

Data is provisionned with flyway, and instructions on how to run it are in the README. Ask me if you need anything else

juliendangers commented 6 years ago

Wow! Thank you so much! You're very responsive, and you're lib is really great.