Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Simple List Parameter could not resolve TypeHandler #506

@GoogleCodeExporter

Description

@GoogleCodeExporter
What version of the MyBatis are you using?

MyBatis 3.0.6.

Please describe the problem.  Unit tests are best!

When the parameter has a simple list attribute and the SQL references the list 
member, it fails and says there was no TypeHandler found.

Here is the case.

    public class Car {
        private List<String> doors;
        ...
    }

    public interface CarMapper {

        @Select({
            "select ID, BRAND from CAR where DOOR = #{doors[2]}"
        })
        List<Car> getMyCars(Car car);
    }

Caused by: org.apache.ibatis.executor.ExecutorException: There was no 
TypeHandler found for parameter doors[2] of statement 
com.mycompany.mapper.CarMapper.getMyCars
    at org.apache.ibatis.executor.parameter.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:71)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:61)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:31)
    at com.sococ.fwork.plugins.OptimisticAccess.intercept(OptimisticAccess.java:102)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:42)
    at $Proxy597.parameterize(Unknown Source)
    ...

However, when using the example class generated by MBG, similar but more 
complex expression could be executed, e.g. 
#{example.oredCriteria[4].allCriteria[2].value}.  It seems if the expression 
has nested list attribute, say #{xxx[n].yyy}, the mapper could handle it by 
using a ObjectTypeHandler but not one level list attribute.  It is also found 
that it would work if the parameter is given the JDBC type, e.g. 
#{doors[2],jdbcType=VARCHAR}.  It seems there is problem with PropertyTokenizer 
that it could not handle property parsing correctly.

Original issue reported on code.google.com by wong...@gmail.com on 2 Feb 2012 at 7:44

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions