亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

mybatis xml注釋sql的注意事項(xiàng)及說明

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

mybatis xml注釋sql的注意事項(xiàng)

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

如代碼段2所示,mysql數(shù)據(jù)庫更換為oracle數(shù)據(jù)庫時(shí),#{date}需要明確jdbcType,而該代碼段中僅將適用于mysql的sql注釋,依舊會(huì)報(bào)同樣的錯(cuò),最好是將注釋的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>

注意事項(xiàng)

1、where語句等用到大于小于等符號(hào)時(shí)候,需要使用 <![CDATA[ > ]]>或者 <![CDATA[ < ]]>進(jìn)行識(shí)別。

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

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

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

ORDER BY eeee ORDER BY rrrrrr

5、SELECT

           CASE
           WHEN  條件1 THEN 字段1

WHEN 條件2 THEN 字段2

           ELSE    字段3
           END
  FROM.....

只要滿足一個(gè)WHEN,后面的WHEN就不會(huì)執(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里面注釋語句的時(shí)候,不要用–,用 <!- -需要注釋的內(nèi)容–>。

總結(jié)

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

相關(guān)文章

最新評(píng)論