MyBatis3 x整理 三 動態SQL

2021-08-31 03:42:22 字數 1381 閱讀 2390

select id,name,sn,salary,deptid from employee

where 1= 1

and (name like # or sn like #)

and salary >= #

and salary <= #

0">

and deptid = #

select id,name,sn,salary,deptid from employee where 1=1

0">

and dept_id = #

and detp_id is not null

select id,name,sn,salary,deptid from employee

and (name like # or sn like #)

and salary >= #

and salary <= #

0">

and deptid = #

update employee

name = #,

sn= #,

salary= #,

delete from employee

#

批量刪除

void batchdelete(@param("ids")long ids)
sql:可以把相同的sql片段起乙個名字,並使用include元素在sql任意位置使用

and (name like # or sn like #)

and salary >= #

and salary <= #

0">

and deptid = #

select id="queryforlist" resulttype="employee">

select id,name,sn,salary,deptid from employee

0">

limit #,#

bind:使用ognl表示式建立乙個變數並將其繫結在上下文中

select id,name,sn,salary,deptid from employee

and (name like # or sn like #)

and salary >= #

and salary <= #

0">

and deptid = #

mybatis 3 x 快取介紹

mybatis快取分為一級快取和二級快取 一級快取是基於 perpetualcache mybatis自帶 的 hashmap 本地快取,作用範圍為session,所以當session commit或close後,快取就會被清空.1 單獨使用mybatis而不繼承spring,使用原生的mybati...

mybatis 3 x 快取Cache的使用

1 namespace 23 cache 4eviction lru 5flushinterval 60000 6size 1024 7readonly true 8 9.10 這裡有幾個要注意的地方 eviction是快取的淘汰演算法,可選值有 lru fifo soft weak 預設值是lru...

mybatis 3 x 快取Cache的使用

1 namespace 23 cache 4eviction lru 5flushinterval 60000 6size 1024 7readonly true 8 9.10 這裡有幾個要注意的地方 eviction是快取的淘汰演算法,可選值有 lru fifo soft weak 預設值是lru...