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!

 

1,160 total views, 4 views today

About Mirthbees 681 Articles
Blogger, Innovator, Developer and Enterpreneur. Founder of GuruRecharge, Readymade online recharge script. Lead Developer in Bookrate.in

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.