再說spring比較重,臃腫的看此文!!!!!

 

springrain地址:http://git.oschina.net/chunanyong/springrainhtml

spring的強大靈活+jfinal的開發效率!git

個人博客:http://www.weicms.net/2012/12/14/spring_super.htmlspring

 

在ssh中,我認爲spring是惟一值得用的框架數據庫

spring mvc 的優勢能夠自行在網絡搜索,特別是3.0以後......我不認爲spring 的controller會比其餘的差!!!!網絡

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

我實在沒法忍受各類軟文說spring 太厚重,臃腫了.如下代碼是個人測試用例.我還真是沒明白,spring複雜到哪了!!!app

controller service  dao Entity 都使用註解,就極簡而言,一個數據庫只須要一個Dao,一個Service 而已!!!框架

//就極簡而言,一個數據庫只須要一個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", 125);
Integer id = baseFangService.queryForObject(finder, Integer.class);
System.out.println(id);

}


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

}
//@Test 調用存儲過程並返回 Map
public void testProc() throws Exception{
	Finder finder=new Finder();
	finder.setParam("unitId", 0);
	finder.setProcName("proc_myproc");
	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", 125);
	String userName= baseFangService.queryForObjectByByFunction(finder,String.class);
	System.out.println(userName);
	

}

//@Test  保存一個對象
public void testRoleModel() throws Exception{
		Re_Role_Model re=new Re_Role_Model();
		re.setRoleId("user");
		re.setBool(1);
		baseFangService.save(re);
	
	
}
相關文章
相關標籤/搜索