A Dynamic Web Project is an Eclipse Java project that contains the source
code, web pages, images, resources, and configuration files for building a web application.
Create new web application project
Choose File > New > Project.
In the New Project dialog, select Examples > Java
Persistence API (JPA) > Workshop JPA Tutorial from the list.
Click Next.
Verify that the value workshop-jpa-tutorial is in the
project name field and click Next.
If a license dialog appears, review the license carefully and if you accept the terms, click I Agree.
Review the Java build settings. By default, workshop-jpa-tutorial/web/WEB-INF/src/java
is selected as the source folder and workshop-jpa-tutorial/web/WEB-INF/classes
as the output folder.
Click Finish to create the new JPA Web Application
project and click Yes to switch to Workshop perspective, if
you are not already in Workshop perspective.
8. Below is a summary of different parts of the web application structure.
Folder or file
Overview
workshop-jpa-tutorial
Project folder with project name.
/web (Web App Root)
Root folder for web application artifacts.
/Faces Configuration
Lists JSF configuration elements.
/JPA Configuration
Displays a list of JPA persistent entities.
/pages
Folder for HTML and JSP presentation pages.
/hsqlDB
Contains Hypersonic Database.
/Resources
Supporting files in a zip format that are
being used in the JPA application.
/WEB-INF
Holds folders / files used as part of the
runtime web application.
/classes
Holds class files for the web application.
/config
Holds JSF configuration files.
/lib
Folder to hold third-party .jar files which
are used at runtime, i.e., .jar files for logging, tag libraries, JDBC
drivers etc.
/src/java
Folder to hold Java source files.
/tld
Folder to hold tag library definition files.
web.xml
Deployment descriptor for the web application.
/web/WEB-INF/src/java
Folder that maps to the src/java
folder where you can place Java source files.
/resources
Folder to place the resource files.
persistence.xml
Persistence configurations file.
application.properties
Application configuration resource file.
/Referenced Types
Java classes referenced by web artifacts.
Connect and analyze database schema using DbXplorer
In this step, we will learn how to explore databases using the DbXplorer.
The BEA Workshop ORM Workbench allows you to connect to any database, analyze
database schemas, tables, columns, and even populate the database with sample
data.
The DbXplorer provides an intuitive interface for database access through
the ORM Workbench. It allows to setup the database connection, review the database
artifacts, query the data in an existing table or column, and generate object
relational mappings.
Create a New Database Connection
Open the DbXplorer View, if it is not visible. To open
the DbXplorer View, click Window > Show
View > DbXplorer.
Right-click anywhere within the DbXplorer view and select New Connection.
In the Add Database Connection wizard, enter a database
connection name. The database connection name can be arbitrary and does not
have to match the actual name of the database server.
In the Add Database Connection dialog, click Add
and select the Hypersonic JDBC driver file, <path to workspace>\workshop-jpa-tutorial\web\WEB-INF\lib\hsqldb.jar.
Click Next.
Click Browse and select org.hsqldb.jdbcDriver
as the Hypersonic JDBC Driver class.
Workshop provides sample Database URL's for some standard databases, which
can be accessed from the Populate from database defaults
pull down menu. Select HypersonicSQL In-Memory.
For database URL jdbc:hsqldb:{db filename}, specify the
Hypersonic database script file location for {db filename} <path to workspace>\workshop-jpa-tutorial\web\hsqlDB\SalesDB
.
For User, enter sa.
Click the Test Connection button to verify the connection
information.
Click Finish. The new database connection should now appear
in DbXplorer.
Browse the database artifacts using DbXplorer
DbXplorer view allows you to browse the database components.
In the DbXplorer view, expand the nodes inside the SalesDBConnection
node. You can view the individual tables and columns. Observe that the DbXplorer
view denotes which columns have been designated as primary keys.
While browsing database artifacts, the Properties view
displays the relevant properties of the component.
For large databases with many schemas, it might be necessary to hide the
schemas not in use. Right-click a schema and select Hide Selected
Schemas to remove it from the DbXplorer view (this step does not
modify the database or the schemas). To display all of the schemas again,
right click the database and select Show Hidden Schemas.
Click one of the following arrows to navigate through the tutorial: