使用mybatis遇到的一些問題

2021-09-04 04:06:26 字數 1548 閱讀 3223

1.使用druid,具有防止sql注入的功能.

springboot + mybatis 在控制台輸出sql語句(主要是配置)

select t1.constant_name as departmentname,

case t2.pool_type

when '1' then '後勤線'

when '2' then '業務線'

when '3' then '物流線'

end as line,

t2.grant_amount as distributeamount,t2.forfeit_amount as forfeitamount,t2.result_amount as grantamount,

t2.surplus_amount as surplusamount

from

t_system_constant t1,

t_bonus_monthly_surplus t2

where t1.constant_key=t2.department_id and t1.constant_type='pool_type' and 1=1

它會把它作為sql注入處理,就會報錯.還有就是order by 排序問題

select t1.constant_name as departmentname,

case t2.pool_type

when '1' then '後勤線'

when '2' then '業務線'

when '3' then '物流線'

end as line,

t2.grant_amount as distributeamount,t2.forfeit_amount as forfeitamount,t2.result_amount as grantamount,

t2.surplus_amount as surplusamount

from

t_system_constant t1,

t_bonus_monthly_surplus t2

where t1.constant_key=t2.department_id and t1.constant_type=# and 1=1

and t2.year = #

and t2.month = #

andfind_in_set(t2.pool_type,#)

and t1.constant_name like #

order by $

引數如下:

map map = maputil

.convert2hashmap("deptname", deptname == null ? "" : "%" + deptname + "%", "str",

s, "orderby", "department_id", "year", year,

"month", month, "constanttype", "bonus_department_info");

find_in_set的用法參考

mybatis初學遇到的一些異常

org.apache.ibatis.exceptions.persistenceexception 這種錯誤還有可能是xml檔案中中文注釋引起的問題 因為對映檔案的引入用的 resource 在這裡插入描述描述 org.apache.ibatis.binding.bindingexception i...

mybatis的一些函式使用

case when user.null then user.返回的資料 when user.is null then 男 返回的資料 else user.end 列名 自己定義同別名 這是拼接列的資料 distinct 是去重複 select group concat distinct name f...

Ubuntu下安裝vsftp遇到的一些問題

1.執行make安裝vsftpd 報告錯誤 undefined reference to crypt 解決方法 開啟makefile vim makefile libs vsf findlibs.sh 末尾增加 lcrypt 變成 libs vsf findlibs.sh lcrypt 2.執行ma...