3
我想在Ibatis select標籤中動態設置表名。IBATIS 2.0動態設置表名
<select id="queryGetTopSongCount" parameterClass="java.lang.String" resultClass="java.lang.Integer">
SELECT
count(0)
FROM
#toptable#
</select>
查詢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
這個問題似乎是與雙引號。如何設置不帶雙引號的字符串參數?
能否請你解釋你得到這個在哪裏?因爲閱讀(舊)文檔無法給出答案:根本沒有關於#和$ https://ibatis.apache.org/docs/java/pdf/iBATIS之間的這種區別的明確/明確的解釋-SqlMaps-2_en.pdf – maxxyme