Book Image

Java EE 5 Development with NetBeans 6

Book Image

Java EE 5 Development with NetBeans 6

Overview of this book

Table of Contents (17 chapters)
Java EE 5 Development with NetBeans 6
Credits
About the Author
About the Reviewers
Preface
Identifying Performance Issues with NetBeans Profiler

Automated Generation of JPA Entities


In the previous section, we saw how we can automatically create database tables from JPA entities. This is an optional feature of the JPA specification, however most JPA implementations implement it. One feature that is not available from JPA is the converse, generating JPA entities from database tables. Luckily for us, NetBeans provides this functionality.

In this section, we will be using a custom database schema. In order to create the schema, we need to execute an SQL script that will create the schema and populate some of its tables. To do this, we need to go to the Services window, right-click on JavaDB, then select Create Database....

We then need to add the database information in the Create Java DB Database wizard.

At this point, we can open the SQL script by going to File | Open File..., then navigating to its location on our disk and opening it.

Note

The file name of our script is create_populate_tables.sql. It is included as part of the source...