MyBatis智慧型標籤

2021-08-03 18:18:33 字數 2411 閱讀 2823

public listfindstudentsbycondition(mapmap);

select * from studentinfo where stuname like '%' # '%' and stuage>#

多條件查詢

@test

public void testselectlike()

session.close();

}}

public listfindstudentsbyconditionmutliargs(string stuname,int stuage);

select * from studentinfo where stuname like '%' # '%' and stuage>#

//多條件查詢

@test

public void testselectlikemulti()

session.close();

}

//智慧型標籤if

public listfindbyif(studentinfo stu);

select * from studentinfo

and stuname like '%' # '%'

and stuage>#

//智慧型標籤if

@test

public void testif()

session.close();

}

//智慧型標籤choose

public listfindbychoose(studentinfo stu);

select * from studentinfo

and stuname like '%' # '%'

and stuage>#

and 1=2

//智慧型標籤choose

@test

public void testchoose()

session.close();

}

//智慧型標籤foreach

public listfindbyforeacharray(int ids);

select * from studentinfo

0">

stuid in

#

//智慧型標籤foreach array

@test

public void testforeacharray();

listlist = dao.findbyforeacharray(ids);

for (studentinfo stuinfo:list)

session.close();

}

//智慧型標籤foreach listpublic  listfindbyforeachlist(listlist);

select * from studentinfo

0">

stuid in

#

//智慧型標籤foreach list@test

public void testforeachliststudent()

session.close();

}

//智慧型標籤foreach listpublic  listfindbyforeachliststudent(listlist);

}

select * from studentinfo

0">

stuid in

#

//.智慧型標籤foreach list@test

public void testforeachliststudent()

session.close();

}

mybatis標籤用法

一 mybatis中的標籤 1.if標籤的用法 select from wx act deadbeat order grab where 1 1 and debt no and grabor id 注 這種我們可以把所有的屬性都加上,然後跟據不同需求使用,比較靈活 2.where標籤的用法 sele...

MyBatis標籤詳解

對映檔案的頂級元素 select 對映查詢語句 insert 對映插入語句 update 對映更新語句 delete 對映刪除語句 sql 給sql 塊重新命名 resultmap cache cache ref 2.select 標籤屬性resultmap 標籤的屬性資訊 insert標籤得屬性資...

mybatis動態標籤

動態條件判斷 select from user where 1 1 and username 動態where select from user username 動態遍歷 select from user where id in 其中 標籤 類似於switch,按順序判斷 when 中的條件出否成立...