我希望您能在Ibatis的select标签中动态设置表名。
我遇到了以下错误:
问题似乎出在双引号上。我们如何在没有双引号的情况下设置字符串参数?
<select id="queryGetTopSongCount" parameterClass="java.lang.String" resultClass="java.lang.Integer">
SELECT
count(0)
FROM
#toptable#
</select>
以下是调用Query GetTopSongCount:
Map<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("toptable", "top_of_week_tab_6_2014");
int totalPagination=(Integer)getMainSqlMapClient().queryForObject(queryGetTopSongCount, toptable);
我遇到了以下错误:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in resources/ibatis/song-sqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the song.queryGetTopSongCount-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''top_of_week_tab_6_2014'' at line 1
问题似乎出在双引号上。我们如何在没有双引号的情况下设置字符串参数?