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

java.lang.IllegalArgumentException: value null at org.simpleflatmapper.ow2asm.SymbolTable.addConstant(SymbolTable.java:515) #753

Open cdxf opened 3 years ago

cdxf commented 3 years ago

I'm using SFM v8.2.3 with Spring JDBC and Java 15 (hasn't tested with other JDK), for the first query I get this error message (even though everything works fine include the first query) image Am I missing something?

ltkn commented 3 years ago

No issues here, Spring boot 2.4.x, jdbcTemplate etc..

Not sure what your problem is though, but might not be related to JDK.

My jdk version (using debian):

openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment Zulu15.29+15-CA (build 15.0.2+7)
OpenJDK 64-Bit Server VM Zulu15.29+15-CA (build 15.0.2+7, mixed mode, sharing)
cdxf commented 3 years ago

@ltkn The error is at this line:

    private final RowMapper<Post> mapper =
            JdbcTemplateMapperFactory.newInstance()
                    .newRowMapper(Post.class);

If I set useAsm to false, it works without any errors

    private final RowMapper<Post> mapper =
            JdbcTemplateMapperFactory.newInstance()
                    .useAsm(false)
                    .newRowMapper(Post.class);

I use Zulu 15 too but this error also happens with other jvm (java 15) image

ltkn commented 3 years ago

No idea unfortunately, but it could help to see your entity class, the query and any nested object ;) Do you have some nested objects in Post entity? with "nestedId" present in Post class, and nested table named "nested" with "id" as primary key? sometimes I find this type of mapping ambiguous.

Also not sure if useAsm is failing with jdk15 because its an old ASM library version https://github.com/arnaudroger/SimpleFlatMapper/tree/master/ow2.asm and if upgrading it is just a matter of changing the version of if it'd come with breaking changes.

I don't think it's related but I'm using ResulsetExtractor instead of RowMapper

@Slf4j
@AllArgsConstructor
@Repository
public class RoleRepository {

    private final ResultSetExtractor<List<Role>> roleEntityRse =
            JdbcTemplateMapperFactory
                    .newInstance()
                    .ignorePropertyNotFound()
                    .unorderedJoin()
                    .addKeys("role_id")
                    .newResultSetExtractor(Role.class);

    private final JdbcTemplate jdbcTemplate;

    @Transactional(readOnly = true)
    public Role findByCode(final String code) {

        final String sql = """
                SELECT * from public.role where code= ?
                """;

        return DataAccessUtils.singleResult(jdbcTemplate.query(sql, roleEntityRse, code));
    }
}