Java Reference
In-Depth Information
The instructions provided here are for deploying to Allaire JRun 3.0. Instructions for installing
JRun are found at the beginning of this chapter, in the section “Installing JRun.”
JRun configures all of its bean information by using a property file. This can be done with a
separate file for each bean. These property files can include all of the necessary information, to
the point where the standard ejb-jar.xml file is not necessary. An alternate route is to include
each of the properties as an environment property in the ejb-jar.xml deployment descriptor.
We will split the difference and use a combination of these two methods. Your deployment
descriptor will include all of the standard information, enabling you to deploy the beans to any
compliant application server. You will also include a property file for the other information to
configure JRun. This information goes in a file named <bean>.properties ; for the Quote
Bean the file name is Quote.properties .
12
The database mappings for the container-managed Quote Bean is the most important informa-
tion you have. This information is always defined differently when deploying to application
servers. JRun requires you to write a SQL statement and bind the bean's attributes to the SQL
statement. A different SQL statement is required for each type of database transaction: cre-
ation, loading, storing, and finding.
The following code snippet contains an example for your load method. This is the database
transaction that will be called when ejbLoad() is invoked by the container and the bean is to
be loaded from the information in the database.
ejipt.loadSQL= SELECT name, phone, amount, pmt, rate
FROM quote WHERE id = ?
ejipt.loadSQL.source= bookDataSource
ejipt.loadSQL.params= id
ejipt.loadSQL.paramTypes= INTEGER
ejipt.loadSQL.fields= customerName, phoneNumber,
loanAmount, monthlyPayment, interestRate
This block of properties includes all of the information necessary to load a Quote Bean from
the database. It also defines which fields to load with the information returned from the query.
The list of properties that JRun accepts is quite extensive. After this property file is completed
for each bean, include it in the jar file.
N OTE
You might wonder about the benefits of container-managed persistence if you still
have to write SQL. There are many pros and cons of both ways of persistence man-
agement, but here all you must do is change a properties file to change the database
mapping or data source.
 
Search WWH ::




Custom Search