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

React.js Tutorial: Consuming JavaEE RESTful Web Services In this post I'm going to show how to consume Web Services with React.js, more specificalyJavaEE RESTful Web Services. I've already written a post showing how to create these web services with EJB 3, if you haven't seen it yet just click on this link for more details, but if you're already familiar ...
Example of ServletContextListener Implementation According to Oracle official documenentation, the ServletContextListener Interface is responsible for receiving notifications about the ServletContext lifecycle changes, more specifically its initialization and destruction. This can be really helpful for developers in some specific situations, like ...
Improve Performance by Increasing Glassfish Memory When a Glassfish domain is created it already comes with a default set of JVM options (including memory related options), as you keep working on your project your application will increasingly grow and consume more memory, until it reaches the point where the default Glassfish memory configuration i...

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>