我正在使用 MyBatis 映射一些需要比较String
参数 ( myString
) 的查询。
我的映射器界面是:
public Map<Integer, String> findSomething(@Param("myString") String myString);
我的XML如下:
<select id="findSomething" parameterType="String" resultType="Map">
SELECT column1 as key,
column2 as value
FROM my_table
<where>
<choose>
<when test="myString == 'xxx'">
column3 = 1
</when>
<when test="myString == 'yyy'">
myColumn = 2
</when>
<when test="myString == 'zzz'">
myColumn = 3
</when>
</choose>
</where>
ORDER BY value;
</select>
当我执行此语句时,会引发以下错误:
ERROR [stderr] Caused by: org.apache.ibatis.exceptions.PersistenceException:
ERROR [stderr] ### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'myString' in 'class java.lang.String'
这样一String
对比,就难闻了。不幸的是,这是数据库建模的方式。
MyBatis 版本:3.2.2