Book Image

Java EE 7 Development with NetBeans 8

By : David R Heffelfinger
5 (1)
Book Image

Java EE 7 Development with NetBeans 8

5 (1)
By: David R Heffelfinger

Overview of this book

Table of Contents (18 chapters)
Java EE 7 Development with NetBeans 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Automated generation of JPA entities


In many projects, we will be working with an existing database schema created by a database administrator. NetBeans can generate JPA entities from an existing database schema, which saves us a lot of potentially tedious work.

In this section, we will use 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. In order to do this, we need to go to the Services window, expand Databases, right-click on JavaDB, and select the Create Database... option.

Then, we need to add the database information in the Create Java DB Database wizard.

At this point, we can open our SQL script file by going to File | Open File... and navigating to its location on our disk and opening it. The filename of our script is create_populate_tables.sql. It is included as part of the source bundle for this chapter. The following screenshot shows the file as soon as we open it in our project...