What do EJB multi-object finder methods return?

From Support
Jump to: navigation, search
What do EJB multi-object finder methods return?

The contents of the Enumeration or Collection must be extracted and then narrowed by using the following method:

javax.rmi.PortableRemoteObject.narrow(Object, Class); So, for example, we have in the file examples/ejb/instructors/InstructorClient.java:

      Address address = new Address(null, null, null, "MA", 0);
      java.util.Iterator instructors = instructorHome.findByAddress(address).iterator();
      while(instructors.hasNext()) {
        Instructor instructor = (Instructor) 
          javax.rmi.PortableRemoteObject.narrow(instructors.next(), Instructor.class);
        System.out.println("findByAddress(state=MA)  : " + instructor.getName());
      }

This is very much in compliance with the EJB specification. It is other products which violate the specification by not supporting the PRO.narrow functionality.

 



Article originally contributed by Borland Developer Support