Creating entities from a database
In many application development scenarios, an application needs to be designed for an existing database or the application development starts after the database has been created. To support such scenarios, Roo provides the database
reverse
engineer
command to auto-generate JPA entities from database metadata. As we'll see later in this recipe, Roo provides incremental database reverse engineering, that is, you can execute the database
reverse
engineer
command each time the database changes occur and leave it up to Roo to update JPA entity definitions based on the changes in the database.
The following figure shows tables of the database that we will reverse engineer using the database
reverse
engineer
command:
Getting ready
Refer to the Generating database metadata recipe to create the Roo project, to create the myflightappdb
database, tables, and views in MySQL, and install the JDBC driver for MySQL.
How to do it...
To create entities from a database, execute...