IntelliJ IDEA Hibernate Annotations TrickSeptember 14th, 2006 by Egor Malyshev
IntelliJ IDEA 6.0 features numerous enhancements for making Java EE development easier and more productive.
EJB relationship diagram builder brings valuable bonus to those who use Hibernate annotations for defining data models in their applications. All the power of the EJB diagram builder is at your disposal. You can get the complete picture of how your Hibernate entities relate one to another, and navigate through their relationships in just a couple of mouse clicks.
Just right-click the persistence unit where your Hibernate annotations are used and select Open ER Diagram. IntelliJ IDEA will build the relationship diagram showing entities and their relationships. Helpful tooltips are available when you hover your mouse pointer over diagram elements.
There’s a small catch, however. If your Hibernate annotations are placed through the Java code somewhere in one of your Java (not Java EE) modules, you will need to peform some initial steps, for the diagram builder to recognize them:
- Create the file named persistence.xml in your module’s META-INF folder.
- Populate it with the stub code as follows:
- Switch to the Java EE Project View and select Java Modules from the tree. You should see the MyHibernateUnit persistence unit.
- Now you can build the diagram that reflects relationships between your Hibernate-annotated entities.