資源簡介
zip中有使用doc還有樣例demo可以導入到myeclipse中測試,改變applicationContext中的數據庫連接信息,在插入一些數據即可。
操作數據庫常用操作就是增刪查改,每做一次就寫一次這些操作太麻煩,也沒必要,特別是寫多條件查詢并分頁時,太痛苦了,所以抽空寫了個dao幫助jar,支持增刪查改,并支持多條件分頁查詢,導入即搞定!媽媽再有不用擔心我的項目了!
代碼片段和文件信息
package?com.liang.demo.action;
import?javax.annotation.Resource;
import?org.springframework.context.annotation.Scope;
import?org.springframework.stereotype.Controller;
import?com.liang.daohelper.entity.Page;
import?com.liang.daohelper.util.QueryHelper;
import?com.liang.demo.entity.Student;
import?com.liang.demo.service.StudentService;
@Controller
@Scope(“prototype“)
public?class?StudentAction?{
@Resource
private?StudentService?studentService;
private?String?name;
private?Double?mathL;
private?Double?mathR;
private?Double?yuwenL;
private?Double?yuwenR;
private?Double?averageL;
private?Double?averageR;
private?Long?ascName=-1L;
private?Long?ascMath=-1L;
private?Long?ascAverage=-1L;
private?Long?currentPage;
private?Long?pageSize=10L;
public?String?list(){
if(currentPage==null){
currentPage=1L;
}
System.out.println(“pageSize:“+pageSize);
System.out.println(“name:“+name);
System.out.println(“mathL:“+mathL);
System.out.println(“mathR:“+mathR);
System.out.println(“yuwenL:“+yuwenL);
System.out.println(“yuwenR:“+yuwenR);
System.out.println(“averageL:“+averageL);
System.out.println(“averageR:“+averageR);
System.out.println(“ascName:“+ascName);
System.out.println(“ascMath:“+ascMath);
System.out.println(“ascAverage:“+ascAverage);
System.out.println(“currentPage:“+currentPage);
Page?page?=?new?QueryHelper(Student.class?“s“)//
.addwhereCondition(name!=null&&name.length()!=0?“s.name=?“?name)//
.addwhereCondition(mathL!=null?“s.math>=?“?mathL)//
.addwhereCondition(mathR!=null?“s.math<=?“?mathR)//
.addwhereCondition(yuwenL!=null?“s.yuwen>=?“?yuwenL)//
.addwhereCondition(yuwenR!=null?“s.yuwen<=?“?yuwenR)//
.addwhereCondition(averageL!=null?“s.average>=?“?averageL)//
.addwhereCondition(averageR!=null?“s.average<=?“?averageR)//
.addOrderByProperty(ascName!=-1?“name“?ascName==0?true:false)//
.addOrderByProperty(ascMath!=-1?“math“?ascMath==0?true:false)//
.addOrderByProperty(ascAverage!=-1?“average“?ascAverage==0?true:false)//
.setPageToActionContext(currentPage?pageSize);
System.out.println(page);
System.out.println(page.getRecordCount());
// for(int?i=0;i<26;i++){
// Student?st=new?Student(“user“+(char)(65+i)?50.+i?60.+i);
// studentService.save(st);
// }
//
return?“list“;
}
public?String?getName()?{
return?name;
}
public?void?setName(String?name)?{
this.name?=?name;
}
public?Double?getMathL()?{
return?mathL;
}
public?void?setMathL(Double?mathL)?{
this.mathL?=?mathL;
}
public?Double?getMathR()?{
return?mathR;
}
public?void?setMathR(Double?mathR)?{
this.mathR?=?mathR;
}
public?Double?getYuwenL()?{
return?yuwenL;
}
public?void?setYuwenL(Double?yuwenL)?{
this.yuwenL?=?yuwenL;
}
public?Double?getYuwenR()?{
return?yuwenR;
}
public?void?setYuwenR(Double?yuwenR)?{
this.yuwenR?=?yuwenR;
}
pub
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-11-07?17:10??daohelper\
?????文件???????52764??2014-11-07?16:40??daohelper\DaoHelper.jar
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\
?????文件????????3593??2014-11-07?13:36??daohelper\demo\.classpath
?????目錄???????????0??2014-11-07?13:19??daohelper\demo\.myeclipse\
?????文件?????????285??2014-11-07?13:35??daohelper\demo\.myme
?????文件????????1277??2014-11-07?13:27??daohelper\demo\.project
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\.settings\
?????文件?????????330??2014-11-07?13:19??daohelper\demo\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\config\
?????文件????????3367??2014-11-07?14:38??daohelper\demo\config\applicationContext.xm
?????文件?????????909??2014-11-07?13:26??daohelper\demo\config\hibernate.cfg.xm
?????文件?????????153??2014-11-06?03:36??daohelper\demo\config\jdbc_mysql.properties
?????文件?????????182??2014-10-17?16:38??daohelper\demo\config\jdbc_oracle.properties
?????文件??????????14??2014-11-05?16:49??daohelper\demo\config\ssh2.properties
?????文件?????????518??2014-11-06?15:20??daohelper\demo\config\struts.xm
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\liang\
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\liang\demo\
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\liang\demo\action\
?????文件????????3966??2014-11-07?16:33??daohelper\demo\src\com\liang\demo\action\StudentAction.java
?????文件?????????411??2014-11-07?14:34??daohelper\demo\src\com\liang\demo\action\TestMain.java
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\liang\demo\entity\
?????文件?????????594??2014-11-07?13:26??daohelper\demo\src\com\liang\demo\entity\Student.hbm.xm
?????文件?????????966??2014-11-07?13:25??daohelper\demo\src\com\liang\demo\entity\Student.java
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\liang\demo\service\
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\src\com\liang\demo\service\impl\
?????文件?????????332??2014-11-07?16:33??daohelper\demo\src\com\liang\demo\service\impl\StudentServiceImpl.java
?????文件?????????186??2014-11-07?16:33??daohelper\demo\src\com\liang\demo\service\StudentService.java
?????目錄???????????0??2014-11-07?16:46??daohelper\demo\WebRoot\
............此處省略175個文件信息
評論
共有 條評論