我有一個查詢映射器類似如下:MyBatis的映射屬性
<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中刪除?
參數類型是一個Java類,如:
這樣的public class SomeType{
private String propertyName;
private String propertyValue;
... getters and setters
}
我按照你所說的解決了它。謝謝。 – John