background image

Automatic Table Generation

<< SummerLeague Class | Building roster Application >>
<< SummerLeague Class | Building roster Application >>

Automatic Table Generation

Automatic Table Generation in the roster Application
At deploytime the Application Server will automatically drop and create the database tables
used by roster. This is done by setting the toplink.ddl-generation property to
drop-and-create-tables
in persistence.xml.
<?xml version=
"1.0" encoding="UTF-8"?>
<persistence xmlns=
"http://java.sun.com/xml/ns/persistence"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
"
version=
"1.0">
<persistence-unit name=
"em" transaction-type="JTA">
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<property name=
"toplink.ddl-generation"
value=
"drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>
This feature is specific to the Java Persistence API provider used by the Application Server, and
is non-portable across Java EE servers. Automatic table creation is useful for development
purposes, however, and the toplink.ddl-generation property may be removed from
persistence.xml
when preparing the application for production use, or when deploying to
other Java EE servers.
Building and Running the roster Application
This section describes how to build, package, deploy, and run the roster application. You can
do this using either NetBeans IDE or Ant.
Building, Packaging, Deploying, and Running roster in NetBeans IDE
Follow these instructions to build, package, deploy, and run the roster example to your
Application Server instance using NetBeans IDE.
1. In NetBeans IDE, select File
Open Project.
2. In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/ejb/.
3. Select the roster folder.
4. Select the Open as Main Project and Open Required Projects check boxes.
5. Click Open Project Folder.
6. In the Projects tab, right-click the roster project and select Run Project.
You will see the following partial output from the application client in the Output tab:
The roster Application
Chapter 26 · Persistence in the EJB Tier
729