代码段4.一个调用
为了避免一次远程调用返回数据库的一行,可以用会话EJB对象将所有的数据打包成单个调用。
public class ServerFacadeBean implements SessionBean
{
...
>// 将行向量返回给客户端
public Vector findPersonsWithFirstName(
String firstName) throws RemoteException
{
Vector vector = new Vector();
Enumeration enumeration = null;
try
{
enumeration = personHome.findPersonsWithFirstName (firstName);
PersonData personData = null;
if ( enumeration != null )
{
while ( enumeration.hasMoreElements() )
{
Person person = (Person)enumeration.nextElement();
personData = person.getPersonData();
vector.addElement(personData);
}
}
}
catch(Exception e)
{
>/* 异常处理 */
}
return vector;
} ...
}
