Generate Persistence Mappings by Database Schema
Monday, April 27th, 2009The upcoming IntelliJ IDEA 8.1.1 includes a new option to generate separate XML mapping per entity.
The upcoming IntelliJ IDEA 8.1.1 includes a new option to generate separate XML mapping per entity.
With IntelliJ IDEA you can quickly generate persistence mappings from any database schema. This feature is not so easy to find, so here’s the tip:
In IntelliJ IDEA HQL console can be used with pure JPA facets (as well as with Hibernate facets) to run JPAQL and HQL queries. All you need is Hibernate libraries and JDBC driver in a module classpath. If persistence.xml contains no Hibernate-specific database connection options, it should be mapped to an existing data source via JPA facet settings.

Tip: HQL console can also be used to generate DDL statements for JPA and Hibernate mappings via its Generate DDL command.
Update: If a Persistence Unit or Session Factory is mapped to a valid local Data Source there is no need to specify JDBC driver jars in a module classpath (Since 8.1.1).
In IntelliJ IDEA you can quickly navigate within JPA/Hibernate ER-Diagram using the File Structure Popup (press Ctrl+F12, or invoke View menu, File Structure Popup command):