我有一个查询映射器,如下所示:
<select id="searchSomething" parameterType="SomeType" resultType="SomeOtherType">
select xxxxx
from T_XXXX
where 1=1
<if test="propertyName == 'userName'">
and USER_NAME = #{propertyValue}
</if>
<if test="propertyName == 'address'">
and ADDRESS = #{propertyValue}
</if>
<if test="propertyName == 'taskDate'">
and TASK_DATE = #{propertyValue}
</if>
<if test="propertyName == 'phone1'">
and PHONE_1 = #{propertyValue}
</if>
<if test="propertyName == 'phone2'">
and PHONE_2 = #{propertyValue}
</if>
...
</select>
有这么多的属性。我怎样才能简单地将属性名称映射到列名称,如下所示:
<select id="searchSomething" parameterType="SomeType" resultType="SomeOtherType">
select xxxxx
from T_XXXX
where 1=1
and
<propertyToColumn property="propertyName" />
= #{propertyValue}
</select>
MyBatis 中有类似“propertyToColumn”的东西吗?
我在 iBatis 中找到了“insertColumnName”,它是从 MyBatis 中删除的吗?
parameterType 是一个 java 类,如:
public class SomeType{
private String propertyName;
private String propertyValue;
... getters and setters
}