Automatically Mapping JPA Entities with Netbeans

Creating the JPA entities manually can be really time consuming, specially if you’re working with a huge database with hundreds of tables. Luckily, Netbeans IDE can automatically create the entities for us, if you want to see how just follow the instructions bellow:

1 – Right click on your package -> New -> Entity Classes from Database:

New Entity Classes From Database
New Entity Classes From Database

2 – A new window will show up, but before you proceed you have to create a data source:

New Data Source
New Data Source

3 – Name it as you like and click on New Database Connection:

New Database Connection
New Database Connection

3 – You’ll be asked to select the database driver and also to provide the connection info, after that just click next and finish:

Providing Connection Info
Providing Connection Info

4 – Now you can already see a list containing your database tables, select the ones you want and click next, another screen with some options will show up but you don’t need to change anything, just hit next again and finish:

Selecting the Tables
Selecting the Tables

5 – That’s it! As you can see you already have the entities:

New Entities
New Entities

Recommended for you

Leave a Reply

Your email address will not be published. Required fields are marked *

Obs: Use the tag <pre lang="LANGUAGE"> to include code blocks to your comment.
Example: <pre lang="javascript"> console.log('Test'); </pre>