2020-08-17

How to check JPA ER Diagram in IntelliJ

When developing with JPA, there are many times when you want to see the relationship between JPA entities at a glance rather than checking the relationship between the actual tables.
In particular, there is a limit to tracking complex relationships between entities only with code.

In this case, IntelliJ supports JPA Entity-based ER Diagram.
You can check it without any special big settings, so let’s see how to do it right away.

1. Enabling JPA Support for your project
Those who have already activated JPA Support for their project can go directly to #2.

First, go to IntelliJ by clicking File -> Project Structure in the upper left corner.



In the Project Structure pop-up, on the left Project Settings item, select Modules -> Main of the project -> +Click the button at the top .


+If you press the button, you can see various supports as below.
Select JPA here.



If you select JPA, you can select JPA Default Provider in the lower right corner as shown below.
Choose the JPA implementation you use.
In general, Hibernate will be the most likely implementation.

Those using Spring Data JPA can also choose Hibernate.



Now this is the end of the project setup.
Let’s open the ER Diagram right away.

2. Open ER Diagram
If you look at the bottom left of IntelliJ , you can see the Persistence tab.
After selecting the tab , right-click on entityManagerFactory and select ER Diagram.

If the entityManagerFactory is not visible, select any entity in the Persistence tab and right-click to see the ER Diagram selection window.



If you select the ER Diagram in this way, you can check the ER Diagram where the Entity relationship is drawn as shown below.



There are several options at the top of the ER Diagram screen.



These options, in turn, can turn on/off the following settings.

Entity property value on/off
Embeddable Entity on/off
SuperClass Entity on/off
You can view only the area you want to see by selectively activating it.

No comments:

Post a Comment