欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mybatis xml注釋sql的注意事項及說明

 更新時間:2023年07月13日 16:00:47   作者:阿杰同學  
這篇文章主要介紹了mybatis xml注釋sql的注意事項及說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

mybatis xml注釋sql的注意事項

說明:在mybatis 的sql里不是不能寫注釋,而是注釋不能有#{},mybatis仍舊會把#{}算成一個帶注入的參數(shù)

如代碼段2所示,mysql數(shù)據(jù)庫更換為oracle數(shù)據(jù)庫時,#{date}需要明確jdbcType,而該代碼段中僅將適用于mysql的sql注釋,依舊會報同樣的錯,最好是將注釋的sql刪除。

 <select id="slectSlagsteelRatioByDate" resultType="java.lang.Double">
--         select slagsteel_ratio FROM process_history WHERE r furnace_num = #{furnaceNum}
--         ORDER BY real_time DESC limit 0,1
select slagsteel_ratio FROM(
 select slagsteel_ratio FROM process_history WHERE real_time &lt;= #{date,jdbcType=TIMESTAMP}
 ORDER BY real_time DESC ) WHERE ROWNUM = 1
</select>

注意事項

1、where語句等用到大于小于等符號時候,需要使用 <![CDATA[ > ]]>或者 <![CDATA[ < ]]>進行識別。

2、如果sql文中有動態(tài)sql文標簽,比如sql文,此時wwww為傳遞的參數(shù),不需用#{wwww }取值,直接使用即可。

3、如果超過一個參數(shù),需要在接口方法的每個參數(shù)定義時候使用@Param注解。

4、order by語句可以使用動態(tài)sql

ORDER BY eeee ORDER BY rrrrrr

5、SELECT

           CASE
           WHEN  條件1 THEN 字段1

WHEN 條件2 THEN 字段2

           ELSE    字段3
           END
  FROM.....

只要滿足一個WHEN,后面的WHEN就不會執(zhí)行了,跳出CASE WHEN 語句

mybatis xml 注釋問題

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘mybatis_plus_first’, mode=IN, javaType=long, jdbcType=null, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).] with root cause

java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

解決辦法

在mybatis里面注釋語句的時候,不要用–,用 <!- -需要注釋的內(nèi)容–>。

總結

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論