Java Reference
In-Depth Information
SELECT * FROM yacht WHERE yacht.capacity > parameter_1
The parameter_1 is passed into the statement at runtime.
In addition to finder methods, you can use EJB QL to do any number of querying activities. EJB QL
allows you to do simple queries; compound queries; queries that invoke the persistent fields of more
than one EJB; queries that use finder methods on other EJBs; and queries that use persistent fields
accessible through a relationship to other EJBs. In other words, EJB QL is a very powerful tool.
However, it has also the following restrictions:
 
Comments are not allowed.
 
Date and time values are in milliseconds and use Java long data type. A date or time literal
should be an integer literal. To generate a millisecond value, you may use the
java.util.Calendar class.
 
Currently, CMP does not support inheritance. For this reason, two entity beans of different types
cannot be compared.
Note
This section covers only the simplified syntax of EJB QL. The full syntax is beyond the
scope of this topic. Interested readers can find a detailed description on EJB QL in
many EJB topics.
By now you have learnt how to develop and deploy CMP EJBs. Let us move on to run the example
application.
Running the Example Application
Remember the yacht club application discussed first in Chapter 20 ? It is uses by a yacht club to
manage its yacht-cruise operation. As a treat, the club offers its member free yacht cruises. The
business process includes the following:
 
Operating the yacht — such as starting, stoping, speeding up and slowing down
 
Checking the status of the yacht — such as current velocity, maximum velocity, current passenger
on board, and so on
 
Picking up club members if there is enough room
 
Dropping off passengers
Over the last three chapters, you have built these three EJBs:
 
Stateful session bean YachtSessionEJB
 
BMP entity bean MemberEJB
 
CMP entity bean YachtEJB .
You can use them to build the simple yacht club application.
As an example, Listing 22-5 shows a JSP client that allows you to manage the yachts that the club
owns.
Listing 22-5: YachtManager.jsp
<%@ page import="javax.naming.*, java.rmi.*, javax.ejb.*, YachtEBean.*,
common.*"
session="true" %>
<%
{
YachtHome home = (YachtHome)ctx.lookup("YachtEJB");
if (request.getParameter("DestroyYacht") != null) {
String pk = null;
Search WWH ::




Custom Search