이 프로세스에서는 두 가지 주요 단계를 수행합니다.
다음의 코드 예제는 이러한 두 단계를 설명합니다.
EmployeeAccessBean aEmployee = new EmployeeAccessBean()
aEmployee.setInit_employeeNo ("100");
aEmployee.setName ("IBM");
aEmployee.setAddress ("1150 Eglinton Ave, Toronto");
클라이언트 프로그램이 액세스 Bean에서 복사 헬퍼 속성을 설정하고 commitCopyHelper()를 호출하기 전에 Get 오퍼레이션을 수행한 경우 액세스 Bean은 엔터프라이즈 Bean의 데이터가 아닌 캐시의 데이터를 리턴합니다. 일반적으로 속성이 캐시에 있으면 액세스 Bean은 캐시에서 가져옵니다. 그러나 설정되거나 검색되지 않은 복사 헬퍼 필드에서 Get 오퍼레이션을 수행하는 경우 엔터프라이즈 Bean에서 캐시를 새로 고칩니다.
열거를 리턴하는 파인더를 호출하고 트랜잭션 범위 외부에 있는 클라이언트 프로그램에서 호출할 경우 처음 다섯 개의 결과만 열거에 리턴됩니다. 모든 결과를 리턴하려면 파인더 메소드가 트랜잭션에서 호출되었는지 확인해야 합니다. 이 경우 메소드에 컨테이너 관리 트랜잭션 속성이 있는 세션 Bean 메소드에서 파인더 메소드를 호출하거나 클라이언트에서 사용자 트랜잭션을 작성할 수 있습니다. 예를 들어, 다음과 같습니다.
// Get the initial context
java.util.Properties p = new java.util.Properties();
p.put(Context.PROVIDER_URL, "IIOP:///");
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext initContext = new InitialContext(p);
// Look up a transaction
userTran = (UserTransaction)initContext.lookup("jta/usertransaction");
userTran.begin();
// Call the finder
// Assume that employeeHome has already been found, and has a method defined findAll()
Enumeration enum = employeeHome.findAll();
while (enum.hasMoreElements()) {
// Process the enumeration
}
userTran.commit();