Module CSC7321—CSN: Middleware and software architecture for Internet distributed applications

Portail informatique

JavaEE Lab 2 — Entity Bean

Configuration

The configuration step should be done as for EJB Lab 1 first and the application server should have been started.

Understand the example source code

Analyse the EJB-Jakarta-3* samples.

The examples use 2 entities: a Customer and an Order, with a OneToMany relationship between them. The Customer and the Order classes are Plain Old Java Classes (POJOs).

The META-INF directory contains a persistence.xml file, where derby is indicated as default in line jdbc/__default. The application is ready to work with the Derby embedded database.

Using a Derby Database

Derby is a relational database corresponding to an implementation of the Java Persistence API (JPA), bundled with glassfish.

See the glassfish quickstart guide to discover more on the basic features of glassfish and the use of derby.

  1. Once the glassfish application server has been started (by asadmin start-domain domain1), you also have to start the database server as follows:
    asadmin start-database
  2. Compile, deploy and run the example by following the instructions in the README.txt file.
  3. Check that the deployment took place properly and that the application appears in the list of deployed components.
    asadmin list-components
  4. To check the content of the Derby database, you can use the ij tool. In a terminal window, launch the following command:
    ij version ij 10.6 ij>
    Then connect to the Derby database and write SQL requests:
    ij> connect 'jdbc:derby://localhost:1527/sun-appserv-samples'; ij> select * from Customer;
  5. Stop the Derby database server:
    asadmin stop-database

Documentation on the Java Persistence Query Language

First step of micro-project

Start the microproject

Develop a client-server application for implementing the first step of the micro-project.