新聞中心
iBATIS模糊查詢的實(shí)現(xiàn)是如何的呢?讓我們先看看例子,仿照J(rèn)ava的Spring+Ibatis+Struct用Castle+IBatisNet+Asp.net的開發(fā)框架的DAO的基類:BaseSqlMapDao內(nèi)定義了一個內(nèi)部類來輔助模糊查詢。內(nèi)部類代碼如下:

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站設(shè)計制作、成都網(wǎng)站制作、杜爾伯特網(wǎng)絡(luò)推廣、重慶小程序開發(fā)、杜爾伯特網(wǎng)絡(luò)營銷、杜爾伯特企業(yè)策劃、杜爾伯特品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供杜爾伯特建站搭建服務(wù),24小時服務(wù)熱線:028-86922220,官方網(wǎng)址:www.cdcxhl.com
- protected internal class KeyWordSearch
- {
- private IList keywordList = new ArrayList();
- public KeyWordSearch(String keywords)
- {
- StringTokenizer splitter = new StringTokenizer(keywords, " ", false);
- string token = null;
- IEnumerator enumerator = splitter.GetEnumerator();
- while (enumerator.MoveNext())
- {
- token = (string)enumerator.Current;
- keywordList.Add("%" + token + "%");
- }
- }
- public IList KeywordList
- {
- get
- {
- return keywordList;
- }
- }
- }
在需要使用iBATIS模糊查詢的數(shù)據(jù)訪問類的方法中使用方法如下:
例如數(shù)據(jù)訪問類PersonInfoDao繼承自BaseSqlMapDao,方法
- ///
- /// 檢索求職者信息,根據(jù)關(guān)鍵字檢索
- ///
- public IList SearchPersonInfoList(string keywords)
- {
- object parameterObject = new KeyWordSearch(keywords);
- return this.ExecuteQueryForList("SearchPersonList", parameterObject);
- }
- select UserId,UserName,Sex,Birthday,Mobile,HomeTel,EMail,LivingArea,
- RegisteredLocus,GraduateSchool,MajorSpecialty,JobExperience,MonthlyPay,
- Special,Resume,city.code,city.name,person.NationId,Nation.NationName,
- person.JobId,job.jobName,person.degreeId,degree.DegreeName
- from Career_PersonInfo person ,Career_Nation nation,Career_Job job,Career_City city,Career_Degree degree
- where person.CityCode = city.code and person.NationId = nation.NationId and person.jobid = job.jobId
- and person.degreeId = degree.degreeId
- lower(job.jobName) like #KeywordList[]#
iBATIS模糊查詢的情況就向你介紹到這里,希望通過例子能夠使你對iBATIS模糊查詢的是實(shí)現(xiàn)有所幫助。
【編輯推薦】
- iBATIS映射文件基礎(chǔ)淺談
- iBATIS ParameterMap配置實(shí)例淺析
- iBATIS ResultMap基礎(chǔ)淺析
- iBATIS CacheModel使用淺析
- iBATIS分頁實(shí)例中ObjectDataSource的應(yīng)用淺析
網(wǎng)頁名稱:iBATIS模糊查詢的實(shí)現(xiàn)實(shí)例淺析
文章源于:http://www.dlmjj.cn/article/djegspo.html


咨詢
建站咨詢
