How to get JPA Project option in Eclipse STS ?

How to get JPA Project option in Eclipse STS ?

By default JPA project option is not there when you check under New project in STS eclipse.

To make it available install hibernate tools plugin(which is currently Jboss Tools)

 

 

Now you will be able to create the JPA Project,

 

Could not find Database perspective in your eclipse ?

Then  you may not have installed the below plugin, which could have caused database perspective issue in your eclipse.

https://stackoverflow.com/questions/7923041/i-dont-have-database-development-perspective-in-eclipse-java-se-ide

 

How to generate JPA entities from the MySQL Database ?

First you need to create the JPA Project (STS New -> JPA Project), not able to see the JPA Project option, then you must install Jboss tools like how I mentioned above.

To create database connections, Window -> Preferences -> Data Management -> Connectivity -> Driver definitions

Connection URL: jdbc:mysql://your_host_ip_only

Database Name: enter_your_database_connection (data schema)

Driver Class: com.mysql.jdbc.Driver

User ID: username

password will be asked in the next screen, enter and save the connection details.

 

Do not forget to download and add mysql jar in the below way,

 

 

To generate the entities, once the JPA project created like mentioned above, then right click on the project created New -> JPA Entities from tables then continue further easy navigations to generate it.

 

While generating the JPA entities, these are generally recommended:

  • Collection type: Set
  • Id: Identity
  • Fetch type: Lazy (for better performance)

And always try to keep all the entity and repository together as separate jar package for better micro servicing!

 

Hope this helps!

 

One comment

  • I

    Hello Im having a problem when establishing the connection through the mysql connector. In the Edit Driver Definition window, under the tab JAR list, I cannot add the jar file of mysql connection, because every button on the right is deactivated (in grey). Can I have some advice on what to do?

Leave a Reply