原文連接:http://wksandy.iteye.com/blog/1443133java
xml中某些特殊符號做爲內容信息時須要作轉義,不然會對文件的合法性和使用形成影響spring
在mapper文件中寫sql語句時,爲避免沒必要要的麻煩(如<等),建議使用<![CDATA[ ]]>來標記不該由xml解析器進行解析的文本數據,由<![CDATA[ ]]>包裹的全部的內容都會被解析器忽略 <![CDATA[ sql語句 ]]> sql
將整個sql語句用<![CDATA[ ]]>標記來避免衝突,在通常狀況下都是可行的,可是若是這樣寫mybatis
就會收到錯誤信息:oracle
org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters. Cause: java.sql.SQLException: 無效的列類型: 1111 ; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; 無效的列類型: 1111; nested exception is java.sql.SQLException: 無效的列類型: 1111app
這是因爲該sql配置中有動態語句(where,if),where,if 條件不能放在<![CDATA[ ]]>中,不然將致使沒法識別動態判斷部分,致使整個sql語句非法.應該縮小範圍,只對有字符衝突部分進行合法性調整ui
還有在向oracle插入數據時,mybatis3報Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters,是因爲參數出現了null值,對於Mybatis,若是進行操做的時候,沒有指定jdbcType類型的參數,mybatis默認jdbcType.OTHER致使,給參數加上jdbcType可解決(注意大小寫)google
http://code.google.com/p/mybatis/issues/detail?id=224&q=Error%20setting%20null%20parameter&colspec=IDspa