iBatis動態傳入表名,欄位名
阿新 • • 發佈:2019-02-19
$和#
public List getProjectCodes(String table, String column, String returnColumn, String value) {
Map map = new HashMap();
map.put("table", table);
map.put("column", column);
map.put("returnColumn", returnColumn);
map.put("value", value);
try {
return dao.queryForList("MapService.getProjectCodes", map);
} catch (SQLException e) {
log.error(e);
throw new RuntimeException(e);
}
}
《select id="getProjectCodes" resultClass="java.lang.String"remapResults="true">
select $returnColumn$ from $table$ where $column$=#value#
《/select>
public List getProjectCodes(String table, String column, String returnColumn, String value) {
Map map = new HashMap();
map.put("table", table);
map.put("column", column);
map.put("returnColumn", returnColumn);
map.put("value", value);
try {
return dao.queryForList("MapService.getProjectCodes", map);
} catch (SQLException e) {
log.error(e);
throw new RuntimeException(e);
}
}
《select id="getProjectCodes" resultClass="java.lang.String"remapResults="true">
select $returnColumn$ from $table$ where $column$=#value#
《/select>