Spring的极简封装:9iuspring

jopen 11年前

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.open-open.com/lib/view/home/1365555462265