java:
public <T extends BasePojo> T find(Class<T> pojoClass, Long id) throws DatabaseException {
SqlBuilder.BEGIN();
SqlBuilder.SELECT("*");
SqlBuilder.FROM(getPojoTabelName(pojoClass));
SqlBuilder.WHERE("id = #{id}");
Map<String, Object> values = new HashMap<String, Object>();
values.put("sql", SqlBuilder.SQL());
values.put("id", id);
return sqlSessionTemplate.selectOne("common.executeSql", values);
}
<select id="executeSelectSql" parameterType="Map" resultMap="hashmap">
${sql}
</select>
1、sql必须用${}的方式,否则会被当成参数占位符?
2、参数(例如本例中中的id)必须用#{}的方式,否则会报错