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.