欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
spring+hibernate多數據源+動(dòng)態(tài)切換 事宜 lazyload一應俱全
 spring+hibernate多數據源+動(dòng)態(tài)切換 事務(wù) lazyload一應俱全

1、使用場(chǎng)景:

  以自己為例,現有一個(gè)后臺管理系統管理著(zhù)游戲數據。以前是一個(gè)后臺地址對應一個(gè)后臺管理一個(gè)游戲后臺,現在改進(jìn)為一個(gè)后臺管理多個(gè)游戲數據。在登錄或者其他地方切換下就可以查詢(xún)數據。

 

2、步驟分為:多數據源配置和動(dòng)態(tài)切換配置和事務(wù)+OpenSessionInViewFilter配置

 

先不考慮動(dòng)態(tài)切換配置,一個(gè)datasource對應一個(gè)sessionFactory對應一個(gè)hibernateTemplate對應一個(gè)transactionManager對應一個(gè)OpenSessionInViewFilter

 

在多數據源模式下有多個(gè)sessionFactory,所以配置hibernateTemplate,transactionManager,OpenSessionInViewFilter的時(shí)候要指定sessionFactory!

 

	<filter>		<filter-name>OpenSessionInViewFilter</filter-name>		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>		<init-param>			<param-name>sessionFactoryBeanName</param-name>			<param-value>sessionFactory1</param-value>		</init-param>	</filter>	<filter-mapping>		<filter-name>OpenSessionInViewFilter</filter-name>		<url-pattern>/*</url-pattern>	</filter-mapping>
  <filter>
		<filter-name>OpenSessionInViewFilter4</filter-name>		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>		<init-param>			<param-name>sessionFactoryBeanName</param-name>			<param-value>sessionFactory4</param-value>		</init-param>	</filter>	<filter-mapping>		<filter-name>OpenSessionInViewFilter4</filter-name>		<url-pattern>/*</url-pattern>	</filter-mapping>

  <bean id="transactionManager4"

		class="org.springframework.orm.hibernate3.HibernateTransactionManager"		autowire="byName">		<property name="sessionFactory" ref="sessionFactory4"></property>	</bean>

 

其中transactionManager有一個(gè)問(wèn)題,就是配置aop的時(shí)候要注意2個(gè)transactionManager不重疊。

 

3、在dao中注入不同的sessionfactory/hibernateTemplate 操作各自所屬數據源數據

	HibernateTemplate hibernateTemplate;	@Resource(name = "hibernateTemplate4")	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {		this.hibernateTemplate = hibernateTemplate;	}
  HibernateTemplate hibernateTemplate;
	@Resource(name = "hibernateTemplate1")	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {		this.hibernateTemplate = hibernateTemplate;	}
 

4、動(dòng)態(tài)切換數據源(用來(lái)切換服務(wù)器)

public class DynamicDataSource extends AbstractRoutingDataSource {	private static final Logger log = Logger.getLogger(DynamicDataSource.class);	@Override	protected Object determineCurrentLookupKey() {		String i=  CustomerContextHolder.getCustomerType();					return i;	}}
  <bean id="dataSource00" class="com.xxx.util.DynamicDataSource">
		<property name="targetDataSources">			<map key-type="java.lang.String">				<entry key="2" value-ref="dataSource2" />				<entry key="1" value-ref="dataSource1" />			</map>		</property>		<property name="defaultTargetDataSource" ref="dataSource1" />	</bean>

 動(dòng)態(tài)切換很簡(jiǎn)單,datasource配置改為AbstractRoutingDataSource實(shí)現類(lèi)指定一個(gè)defaultTargetDataSource和targetDataSources

在需要切換的地方

public class CustomerContextHolder {	private static final ThreadLocal contextHolder = new ThreadLocal();	public static void setCustomerType(String customerType) {		contextHolder.set(customerType);	}	public static String getCustomerType() {		return (String) contextHolder.get();	}	public static void clearCustomerType() {		contextHolder.remove();	}}
 CustomerContextHolder.setCustomerType("2");//切換key為2的數據源
User uu = userService.get(User.class, "id = ?", 3l);
就這樣查詢(xún)出來(lái)的就是第二個(gè)數據源的數據了

 

 不出意外的話(huà),是可以看到效果的。如果出現了事務(wù)問(wèn)題就要查找下是否sessionfactory和aop配置正確。如果你把一個(gè)service類(lèi)在aop中配置2次會(huì )出現錯誤的。

多數據源:管理系統數據源+游戲數據源

動(dòng)態(tài)切換:游戲數據各服務(wù)器之間切換。

1 樓 ak121077313 2011-04-15  
謝謝:http://guoweisong.iteye.com/blog/751482

雖然他也是轉載的,雖然找不到原博主,雖然上面描述的事務(wù)問(wèn)題沒(méi)有遇到

但是描述的很詳細,分析步驟很清晰!
2 樓 ak121077313 2011-04-15  
我發(fā)現一個(gè)奇怪的問(wèn)題,就是動(dòng)態(tài)切換的時(shí)候ThreadLocal 居然沒(méi)有保持set進(jìn)去的值

private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

-------------------------

這個(gè)地方不要用ThreadLocal 。。。 設置一個(gè)static變量來(lái)保存key值就行了。
3 樓 elvishehai 2011-04-16  
感覺(jué)這種設計方式不是很好吧,
4 樓 wm920 2011-04-16  
大型的項目當中是不能切換數據源


不然會(huì )存在數據唯一性 的問(wèn)題




5 樓 fairplay 2011-04-16  
LZ有沒(méi)想過(guò)用JTA做?
用JOTM配合JTA,配置多個(gè)數據源,多個(gè)seesionfactory
還能確保事務(wù)一致呢
6 樓 aa87963014 2011-04-17  
fairplay 寫(xiě)道
LZ有沒(méi)想過(guò)用JTA做?
用JOTM配合JTA,配置多個(gè)數據源,多個(gè)seesionfactory
還能確保事務(wù)一致呢

jta沒(méi)用過(guò)。 上面說(shuō)的大概對于簡(jiǎn)單的系統沒(méi)什么問(wèn)題

數據唯一性 是什么問(wèn)題?。不切換數據源怎么看多個(gè)數據庫的數據?

還有我這個(gè)系統2個(gè)數據源的數據沒(méi)有關(guān)聯(lián)的。
7 樓 371937605 2011-04-20  
這種多數據源的還是用jta來(lái)得方便,JOTM就足夠了,或者用一些容器的實(shí)現,比如websphere,不明白的是為啥要切換數據源,切換seesionfactory 不可以嗎,可以仿照spring的多數據源實(shí)現一下就可以了,這個(gè)地方不太明白
8 樓 ak121077313 2011-04-20  
371937605 寫(xiě)道
這種多數據源的還是用jta來(lái)得方便,JOTM就足夠了,或者用一些容器的實(shí)現,比如websphere,不明白的是為啥要切換數據源,切換seesionfactory 不可以嗎,可以仿照spring的多數據源實(shí)現一下就可以了,這個(gè)地方不太明白

你沒(méi)明白使用場(chǎng)景,多數據源歸多數據源 動(dòng)態(tài)切換歸動(dòng)態(tài)切換。
9 樓 371937605 2011-04-20  
ak121077313 寫(xiě)道
371937605 寫(xiě)道
這種多數據源的還是用jta來(lái)得方便,JOTM就足夠了,或者用一些容器的實(shí)現,比如websphere,不明白的是為啥要切換數據源,切換seesionfactory 不可以嗎,可以仿照spring的多數據源實(shí)現一下就可以了,這個(gè)地方不太明白

你沒(méi)明白使用場(chǎng)景,多數據源歸多數據源 動(dòng)態(tài)切換歸動(dòng)態(tài)切換。

每個(gè)seesionfactory 榜定一個(gè)數據源,多個(gè)seesionfactory 不就是多數據源了嗎?
動(dòng)態(tài)的切換seesionfactory 不就是切換數據源了嗎,可能我真沒(méi)理解,哈哈
10 樓 songfan55 2011-04-23  
哈哈,我遇到一個(gè)更變態(tài)的需求(政府的項目),需求:比如有一個(gè)總公司下面有各個(gè)相對獨立的子公司,同樣的項目要部署到各個(gè)子公司,子公司都是獨立的數據庫。但是項目中有一個(gè)模塊是任意一個(gè)子公司都可以向其他子公司發(fā)起一種請求,被請求的子公司要做相應的請求。(數據庫都必須是獨立的,至少有50個(gè)以上的子公司)
11 樓 yin_bp 2011-05-07  
songfan55 寫(xiě)道
哈哈,我遇到一個(gè)更變態(tài)的需求(政府的項目),需求:比如有一個(gè)總公司下面有各個(gè)相對獨立的子公司,同樣的項目要部署到各個(gè)子公司,子公司都是獨立的數據庫。但是項目中有一個(gè)模塊是任意一個(gè)子公司都可以向其他子公司發(fā)起一種請求,被請求的子公司要做相應的請求。(數據庫都必須是獨立的,至少有50個(gè)以上的子公司)

你可以看看開(kāi)源項目bbossgroups的持久層框架,可以方便地動(dòng)態(tài)指定數據庫操作所對應的數據庫,看看能不能滿(mǎn)足你的需求,呵呵,以下是一個(gè)測試用例:
/* *  Copyright 2008 biaoping.yin * *  Licensed under the Apache License, Version 2.0 (the "License"); *  you may not use this file except in compliance with the License. *  You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * *  Unless required by applicable law or agreed to in writing, software *  distributed under the License is distributed on an "AS IS" BASIS, *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  See the License for the specific language governing permissions and *  limitations under the License. */package org.frameworkset.spi.mvc;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import org.junit.Test;import com.frameworkset.common.poolman.Record;import com.frameworkset.common.poolman.SQLExecutor;import com.frameworkset.common.poolman.handle.NullRowHandler;import com.frameworkset.common.poolman.handle.RowHandler;import com.frameworkset.util.ListInfo;public class SimpleApiTest {	@Test	public void insertOpera()throws SQLException	{		ListBean lb = new ListBean();		lb.setFieldLable("tttt");		lb.setFieldName("testttt");		lb.setFieldType("int");		lb.setIsprimaryKey(false);		lb.setRequired(true);		lb.setSortorder("ppp");		lb.setFieldLength(20);		lb.setIsvalidated(6);				//用List存放Bean,在某特定的連接池中進(jìn)行crud操作		List<ListBean> beans = new ArrayList<ListBean>();		beans.add(lb);				String sql = "insert into LISTBEAN(ID,FIELDNAME,FIELDLABLE,FIELDTYPE,SORTORDER,ISPRIMARYKEY,REQUIRED,FIELDLENGTH,ISVALIDATED) " +				"values(#[id],#[fieldName],#[fieldLable],#[fieldType],#[sortorder]," +				"#[isprimaryKey],#[required],#[fieldLength],#[isvalidated])";		SQLExecutor.insertBeans("mysql",sql,beans);				 				SQLExecutor.insertBean("mysql", sql, lb);				SQLExecutor.insertBeans("mysql", sql, beans);								SQLExecutor.insertBean(sql, lb);								sql ="insert into LISTBEAN(ID,FIELDNAME,FIELDLABLE,FIELDTYPE) " +		"values(?,?,?,?)";//		SQLExecutor.insert(sql,122,lb.getFieldName(),lb.getFieldLable(),lb.getFieldType());				 //		SQLExecutor.insertWithDBName("mysql", sql,101,"insertOpreation","ttyee","int");							}		@Test	public void updateOpera() throws SQLException	{		//在某特定的連接池中直接crud對象		ListBean bean = new ListBean();		bean.setId(88);		bean.setFieldLable("tttt");		bean.setFieldName("test");		bean.setFieldType("int");		bean.setIsprimaryKey(false);		bean.setRequired(true);		bean.setSortorder("ppp");		bean.setFieldLength(20);		bean.setIsvalidated(6);		List<ListBean> beans = new ArrayList<ListBean>();		String sql ="";		beans.add(bean);				sql ="update LISTBEAN set FIELDNAME='yyyy' where ID=#[id]"; 		SQLExecutor.updateBeans("mysql", sql, beans);				sql ="update LISTBEAN set FIELDNAME=#[fieldName] where ID=#[id]"; 		SQLExecutor.updateBean(sql,bean);				sql ="update LISTBEAN set FIELDNAME=#[fieldName] where ID=#[id]"; 		SQLExecutor.updateBean("mysql",sql,bean);						sql ="update LISTBEAN set FIELDNAME=#[fieldName] where ID=#[id]"; 		SQLExecutor.updateBeans(sql,beans);				sql = "update LISTBEAN set FIELDNAME=? where ID=?";		SQLExecutor.update(sql, "mytest",100);				sql = "update LISTBEAN set FIELDNAME=? where ID=?";		SQLExecutor.updateWithDBName("mysql", sql, "zhansans",101);					}		@Test	public void deleteOpera() throws SQLException	{   //在特定的連接池中對數組對象進(jìn)行crud		ListBean lb = new ListBean();		lb.setId(85);		lb.setFieldLable("tttt");		lb.setFieldName("testttt");		lb.setFieldType("int");		lb.setIsprimaryKey(false);		lb.setRequired(true);		lb.setSortorder("ppp");		lb.setFieldLength(20);		lb.setIsvalidated(6);		ListBean lb2 = new ListBean();		lb2.setId(15);		lb2.setFieldName("this is lb2");				List<ListBean> beans = new ArrayList<ListBean>();		beans.add(lb);		beans.add(lb2);        String sql = "";				sql = "delete from LISTBEAN where ID=?";		SQLExecutor.delete(sql,68);				sql = "delete from LISTBEAN where ID=?";		SQLExecutor.deleteByKeys(sql,67);				sql ="delete  from LISTBEAN where ID=#[id]"; 		SQLExecutor.deleteBean(sql,lb);				sql = "delete from LISTBEAN where ID=#[id]";		SQLExecutor.deleteBeans(sql, beans);				sql ="delete  from LISTBEAN where ID=#[id]";   		SQLExecutor.deleteBean("mysql",sql,lb);				sql ="delete  from LISTBEAN where ID=#[id]";   		SQLExecutor.deleteBeans("mysql",sql,beans);				sql = "delete from LISTBEAN where ID=?";		SQLExecutor.deleteWithDBName("mysql", sql, 3);				sql = "delete from LISTBEAN where FIELDNAME=?";		SQLExecutor.deleteByKeysWithDBName("mysql", sql,"pppp");					}			@Test	public void queryOprea() throws SQLException{		List<ListBean> beans = null;	    		String sql ="select * from LISTBEAN where ID=?";				sql = "select * from LISTBEAN where id=?";		List<ListBean> lbs = (List<ListBean>) SQLExecutor.queryList(ListBean.class, sql,22);				sql = "select * from LISTBEAN where fieldName=?";		beans = (List<ListBean>) SQLExecutor.queryListWithDBName(ListBean.class,"mysql",sql,"testttt");		for(int i=0;i<beans.size();i++)		System.out.println(beans.get(i).getId());				sql = "select * from LISTBEAN where fieldName=?";		List<ListBean> dbBeans  =  (List<ListBean>) SQLExecutor.queryListWithDBName(ListBean.class, "mysql", sql, "testttt");		for(int i=0;i<dbBeans.size();i++)			System.out.println(dbBeans.get(i).getFieldName());				sql = "select * from LISTBEAN where fieldName=? and id=?";		ListBean bean = SQLExecutor.queryObject(ListBean.class, sql,"object",22);		System.out.println(bean.getId());				sql="select * from LISTBEAN where FIELDNAME=? or id=?";        lbs = (List<ListBean>) SQLExecutor.queryList(ListBean.class, sql, "testttt",100);						sql = "select FIELDNAME from LISTBEAN where ID=?";		String lbs1 = SQLExecutor.queryField(sql,2);		System.out.println(lbs1);				sql="select FIELDNAME from LISTBEAN where  ID=?";		String result = SQLExecutor.queryFieldWithDBName("mysql", sql, 100);		System.out.println(result);				sql = "select * from LISTBEAN where ID=?";		ListBean lb = (ListBean)SQLExecutor.queryObjectWithDBName(ListBean.class,"mysql",sql,20);						sql="select * from LISTBEAN where ID<? and ID>?";		ListInfo lif = SQLExecutor.queryListInfo(ListBean.class, sql, 0, 10, 20,10);		beans = lif.getDatas();		for(int i=0;i<beans.size();i++)		System.out.println(beans.get(i).getFieldName()+".......");					     bean = new ListBean();	    bean.setFieldName("testttt");	    bean.setFieldLable("lisi");	            sql ="select * from LISTBEAN where ID=?";				//		bean = (ListBean)SQLExecutor.queryObjectBean(ListBean.class, sql, bean);	    		sql ="select * from LISTBEAN where FIELDNAME=#[fieldName]";		 result = SQLExecutor.queryFieldBean(sql, bean);		System.out.println(result);		result = SQLExecutor.queryFieldBeanWithDBName("mysql", sql, bean);		System.out.println(result);				beans = (List<ListBean>) SQLExecutor.queryListBean(ListBean.class, sql, bean);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getId());								beans = (List<ListBean>) SQLExecutor.queryListBeanWithDBName(ListBean.class, "mysql", sql, bean);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getId());				sql = "select * from LISTBEAN where ID>?";		lif = SQLExecutor.queryListInfoWithDBName(ListBean.class, "mysql", sql, 0, 10,80);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getFieldName()+"^^^^^");				sql = "select * from LISTBEAN where FIELDNAME=#[fieldName]";		lif = SQLExecutor.queryListInfoBean(ListBean.class, sql, 0, 4, bean);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getId());								lif = SQLExecutor.queryListInfoBeanWithDBName(ListBean.class, "mysql", sql, 0, 5, bean);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getId());								bean = SQLExecutor.queryObjectBeanWithDBName(ListBean.class, "mysql", sql, bean);		System.out.println(bean.getId());							}		@Test	public void rowHandlerQuery() throws SQLException{		String sql ="";		List<ListBean> beans = null;		ListBean bean = new ListBean();		ListInfo lif = new ListInfo();		final List<ListBean> lbs = new ArrayList<ListBean>();	    bean.setFieldName("testttt");	    bean.setFieldLable("lisi");			    sql ="select * from LISTBEAN where ID=?";	    	    SQLExecutor.queryByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, sql, 22);	    System.out.println(lbs.size()+"9999999");	    				sql = "select * from LISTBEAN where ID>?";		beans = (List<ListBean>) SQLExecutor.queryListByRowHandler(new RowHandler(){			@Override			public void handleRow(Object rowValue, Record record)					throws Exception {				System.out.println("queryListByRowHandler test Result**:"+record.getString("fieldName"));				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, ListBean.class, sql, 80);		for(int i=0;i<lbs.size();i++)		System.out.println(lbs.get(i).getId()+"*****");										lbs.clear();		System.out.println(lbs.size());		lif = SQLExecutor.queryListInfoByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class, sql, 0, 10, 20);		System.out.println(lif.getTotalSize()+"----");										sql = "select * from LISTBEAN where FIELDNAME=#[fieldName]";		lbs.clear();		beans = (List<ListBean>) SQLExecutor.queryListBeanByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class, sql, bean);		for(int i=0;i<beans.size();i++)		System.out.println(beans.get(i).getId()+"  ggg");										lbs.clear();		beans = (List<ListBean>) SQLExecutor.queryListBeanWithDBNameByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				// TODO Auto-generated method stub				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class, "mysql", sql, bean);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getId()+"  ccccccccc");						lbs.clear();		lif = (ListInfo) SQLExecutor.queryListInfoBeanByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				// TODO Auto-generated method stub				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}},ListBean.class, sql, 5, 5, bean);		beans = lif.getDatas();		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getId()+"  ddddddddddddddddddddddddd");						lbs.clear();		lif = SQLExecutor.queryListInfoBeanWithDBNameByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				// TODO Auto-generated method stub				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}},ListBean.class, "mysql",sql, 0, 5, bean);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getId()+"  ffff");				sql = "select * from LISTBEAN where ID=#[id]";		bean.setId(2);		ListBean  lb1 =SQLExecutor.queryObjectBeanByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				// TODO Auto-generated method stub				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));							}}, ListBean.class, sql, bean);		System.out.println(lb1.getFieldName());				sql = "select * from LISTBEAN where ID<?";		lbs.clear();		lif = SQLExecutor.queryListInfoWithDBNameByRowHandler(new RowHandler(){			@Override			public void handleRow(Object rowValue, Record record)					throws Exception {				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lbs.add(lb);				lb.setFieldName(record.getString("fieldName"));			}},ListBean.class,"mysql", sql, 0, 5, 20);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getId()+"  kkkk");								beans = (List<ListBean>) SQLExecutor.queryListWithDBNameByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {			rowValue.setId(record.getInt("id"));			rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class, "mysql", sql, 20);		for(int i=0;i<beans.size();i++)			System.out.println(beans.get(i).getFieldName()+"  wwwww");				ListBean lb3 = SQLExecutor.queryObjectByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class, sql, 20);		System.out.println(lb3.getFieldName()+"lbbbbb");				ListBean lb4 = SQLExecutor.queryObjectWithDBNameByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class,"mysql", sql, 20);		System.out.println(lb4.getFieldName()+"lb4444");		sql = "select * from LISTBEAN where ID=#[id]";				ListBean lb2 = SQLExecutor.queryObjectBeanWithDBNameByRowHandler(new RowHandler<ListBean>(){			@Override			public void handleRow(ListBean rowValue, Record record)					throws Exception {				// TODO Auto-generated method stub				rowValue.setId(record.getInt("id"));				rowValue.setFieldName(record.getString("fieldName"));			}}, ListBean.class, "mysql", sql, bean);		System.out.println(lb2.getId()+"++++");	}		@Test	public void nullRowHandlerQuery() throws SQLException{		String sql = "";		List<ListBean> beans = null;		ListBean b = new ListBean();	    b.setFieldName("testttt");	    b.setFieldLable("lisi");	    	    		sql = "select * from LISTBEAN where id>?";		beans = null;		final List<ListBean> lbs = new ArrayList<ListBean>();				ListInfo lif = SQLExecutor.queryListInfoByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);				System.out.println("queryListInfoByNullRowHandler test result:"+record.getInt("id"));							}}, sql, 0, 5, 10);		beans = (List<ListBean>)lif.getDatas();//		for(int i=0;i<beans.size();i++)//		  System.out.println(beans.get(i).getId()+".......");		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getFieldName()+"####");				lbs.clear();		lif =SQLExecutor.queryListInfoWithDBNameByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);				System.out.println("queryListInfoByNullRowHandler test result:"+record.getInt("id"));							}},"mysql", sql, 0, 5, 10);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getFieldName()+"oooooooo");						lbs.clear();		SQLExecutor.queryWithDBNameByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, "mysql", sql, 80);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getFieldName()+"ppppp");				sql = "select * from LISTBEAN where FIELDNAME=#[fieldName]";		lbs.clear();		SQLExecutor.queryBeanByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, sql, b);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getId()+"yyyyy");				lbs.clear();		SQLExecutor.queryBeanWithDBNameByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, "mysql",sql, b);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getId()+"rrrrrrr");				lbs.clear();		lif = SQLExecutor.queryListInfoBeanByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, sql, 0, 5, b);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getId()+"eeee");				SQLExecutor.queryListInfoBeanWithDBNameByNullRowHandler(new NullRowHandler(){			@Override			public void handleRow(Record record) throws Exception {				// TODO Auto-generated method stub				ListBean lb = new ListBean();				lb.setId(record.getInt("id"));				lb.setFieldName(record.getString("fieldName"));				lbs.add(lb);			}}, "mysql",sql, 0, 5, b);		for(int i=0;i<lbs.size();i++)			System.out.println(lbs.get(i).getId()+"-----");							}	}
12 樓 kewei89767396 2011-11-15  
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
關(guān)于OpenSessionInView
hibernate exception 報錯 異?!局攸c(diǎn)】【總結】
OpenSessionInViewFilter 配置解決延遲加載
Spring?的OpenSessionInViewFilter簡(jiǎn)介
關(guān)于OpenSessionInViewFilter
OpenSessionInViewFilter更新問(wèn)題
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久