我写了个查询接口,传入的参数是个Map,写SQL的时候,我在parameterType填写java.util.Map,调用居然报错,类型转换错误,String转map失败.我把parameterType改为String就没报错,结果出来了,但是我传入的是2个值啊!!!!!真崩溃~!
代码如下:
接口:
报错的XML:
修改为这样就正常了:
但是我SQL里是多个参数啊,不应该用Map么???求大神解答疑惑
PHP中文网2017-04-18 10:53:33
Because you did not specify @Param
注解,当此时只有一个参数的时候,会自动拆开。Map 类型会按 <String, Object>
拆开。复杂数据类型会根据 getter
to disassemble it in the method of mapper interface.
You can refer to this: https://my.oschina.net/triday... .
PHPz2017-04-18 10:53:33
It may be that the interface Map does not have a specified type. It is recommended to make some modifications:
public Module selectByMap(Map<String, Object> map)
天蓬老师2017-04-18 10:53:33
Owner, I am encountering the same problem as you. According to your comment reply, the parameter type in the mapper file is changed to hashMap. The DAO layer does not need any annotations. The value syntax in the sql statement is the same as yours, but it still does not work. Get the value and solve