I'm new to myBatis and I need to put where statement inside my query.
My mapper is defined in this way:
<select id="findMyTableByWhereCondition" parameterType="map" resultMap="mytable">
SELECT *
FROM mytable m
<where>#{whereCondition}</where>
</select>
My Dao:
public List<MyTalbe> findMyTableByWhereCondition(String whereCondition) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("whereCondition", "m.name = 'Test' and m.surname= 'Test'");
return sqlSession.selectList("findMyTableByWhereCondition", param );
}
When I try to execute this query, i get "Invalid relational operator". What is the best practice to handle this kind of query? I need to replace it over the "where" because this might change too often and it may even be very complex.
Thanks in advance