Spring的極簡封裝:9iuspring

jopen 11年前發布 | 19K 次閱讀 Spring JEE框架

9iuspring,spring的極簡封裝,spring的強大靈活+jfinal的開發效率

spring的良好的擴展性,集成度,IOC,AOP事務,已經是項目的基礎條件.

整個項目只使用了spring 沒有struts,沒有hibernate

//就極簡而言,一個數據庫只需要一個Service,就可以查詢這個數據庫的任意一張表

一些測試案例:

//@Test  查詢基本類型
public void testObject() throws Exception{
        Finder finder=new Finder("select id from [Users] where 1=1 ");
        finder.append("and userId=:userId").setParam("userId", 6);
Integer id = baseFangService.queryForObject(finder, Integer.class);
System.out.println(id);

}


//@Test 查詢日期
public void testObjectDate() throws Exception{
        Finder finder=new Finder("select cteateTime from Users where id=6 order by id");
        Date id = baseFangService.queryForObject(finder, Date.class);
System.out.println(id);

}


//@Test 查詢一個對象
public void testObjectUser() throws Exception{
        Finder finder=new Finder("select * from Users where id=6 order by id");
        Users u = baseFangService.queryForObject(finder, Users.class);
    System.out.println(u.getName());

}
//@Test 查詢分頁
public void testMsSql() throws Exception{
        Finder finder=new Finder("select * from Users order by id");
List<Users> list = baseFangService.queryForList(finder, Users.class, new Page(2));
System.out.println(list.size());
 for(Users s:list){
         System.out.println(s.getName());
 }
}



//@Test 調用數據庫存儲過程
public void testProc() throws Exception{
        Finder finder=new Finder();
        finder.setParam("unitId", 0);
        finder.setProcName("proc_up");
        Map queryObjectByProc = (Map) baseFangService.queryObjectByProc(finder);
        System.out.println(queryObjectByProc.get("#update-count-10"));


}

//@Test 調用數據庫函數
public void testFunction() throws Exception{
        Finder finder=new Finder();

        finder.setFunName("fun_userId");
        finder.setParam("userId", 6);
        String userName= baseFangService.queryForObjectByByFunction(finder,String.class);
        System.out.println(userName);


}

項目主頁:http://www.baiduhome.net/lib/view/home/1365555462265

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!