在sql中,存在兩種註釋方式。java
單行註釋: -- spring
多行註釋:/**/sql
因爲項目要求,就在sqlmap中都是用了單行註釋。app
可是在運行時候,發生瞭如下錯誤:code
org.springframework.jdbc.InvalidResultSetAccessException: SqlMapClient operation; invalid ResultSet access for SQL []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in XXXXXXXXXX.xml. --- The error occurred while applying a parameter map. --- Check the sqlID-InlineParameterMap. --- Check the parameter mapping for the 'XXXXXX' property. --- Cause: java.sql.SQLException: 列索引が無効です。
查來查去沒有頭緒。xml
突然發現,在控制檯中,sql語句都打成了一行。索引
這樣就致使,第一個單行註釋就將後面全部的sql都註釋掉了。io
因此,在sqlmap中,使用多行註釋比較靠譜。jdbc