ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
Listing 12: Deployment descriptor for
findAll()
query
UserBean
UserBean
findAll
select Object(theUser) from UserBean as theUser
Also note that the finder method
findAll()
is defined using the query element. The
query element defines the method name, and method parameters in this case
findAll()
and no parameters. Note that the body of the ejb ql element defines the
actual query
select Object(theUser) from UserBean as theUser
. This
syntax is very similar to SQL.
Next I will demonstrate using the
findAll()
method from the session bean by
implmenting a
getUsers()
method.
Adding a
getUsers()
methods to the
UserManagementBean
To use the home interfaces
findAll()
method, you add a
getUsers()
method to
the
UserManagementBean
. The implementation of
getUsers()
in the
UserManagementBean
class calls the
findAll()
method. It then iterates through
the collection of
LocalUser
objects and puts their email property in an ArrayList. The
getUsers()
method cannot simply return the
Collection
sent by
findAll()
since
a local bean can not be sent remotely.
Listing 13: Interface for
getUsers()
/** Add the getUsers method to the interface */
public interface UserManagement extends EJBObject {
public Collection getUsers() throws RemoteException;
}
Page 44 of 48
Introducing EJB CMP/CMR, Part 1 of 2






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

tomcat web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved