?? client2.java~42~
字號:
package client;
import javax.rmi.PortableRemoteObject;
import prj32_1.CustomerBmpRemoteHome;
import prj32_1.CustomerBmpRemote;
/*
池里面的對象是可以被重用的(空殼,只含主鍵,并且主鍵會可能被覆蓋)
1:findByXXXX方法,系統為生成一個對象放在池里面,為了節省內存考慮
2:調用get,set函數,bean都會到達準備狀態
*/
public class Client2 {
public static void main(String args[]) throws Exception{
Object obj = EjbFactory.getEjbHome("CustomerBmp");
CustomerBmpRemoteHome home = (CustomerBmpRemoteHome) PortableRemoteObject.
narrow(obj, CustomerBmpRemoteHome.class);
//查詢1
CustomerBmpRemote remote1 = home.findByPrimaryKey("0008");//0008載入這個Bean
//查詢2
CustomerBmpRemote remote2 = home.findByPrimaryKey("0009");//0009載入這個Bean,覆蓋掉0008,但是0008是被保存在context中,可以通過ejbActivate來得到
System.out.println(remote1.getAccount());//如果在get函數調用時,池中沒有相應的Bean,系統就在context中尋找相應的主鍵,來生成Bean
System.out.println(remote2.getAccount());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -