O'Reilly logo

Enterprise JavaBeans 3.0, 5th Edition by Bill Burke, Richard Monson-Haefel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter WORKBOOK 7. Exercises for Chapter 9

chapter-9 of the EJB book introduced you to the javax.persistence.Query interface as well as the intricacies of EJB QL. The exercises in this chapter explore the Query API and provide examples of base EJB QL features.

Exercise 9.1: Query and EJB QL Basics

This exercise is made up of several example programs to illustrate the Query API and the basic features of EJB QL. The example programs run outside of the application server, so there is no need to start up JBoss.

Initialize the Database

The standalone Java Persistence solution initializes the Hypersonic SQL database and generates the database schema each time one of the sample programs is run. This is an in-memory database, so you will not see any files created for the database.

Build the Example Programs

Perform the following steps:

  1. Open a command prompt or shell terminal and change to the ex09_1 directory created by the extraction process.

  2. Set the JAVA_HOME and JBOSS_HOME environment variables to point to where your JDK and JBoss 4.0 are installed. Examples:

    Windows:
    C:\workbook\ex09_1> set JAVA_HOME=C:\jdk1.5.0
    C:\workbook\ex09_1> set JBOSS_HOME=C:\jboss-4.0.x
    Unix:
    $ export JAVA_HOME=/usr/local/jdk1.5.0
    $ export JBOSS_HOME=/usr/local/jboss-4.0
  3. Add ant to your execution path. Ant is the build utility.

    Windows:
    C:\workbook\ex09_1> set PATH=..\ant\bin;%PATH%
    Unix:
    $ export PATH=../ant/bin:$PATH
  4. Perform the build by typing ant.

Example Basics

Each example program starts off in the same way. It creates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required