Hibernate Reverse Engineering for Netbeans 6.5

This document describes how the implementation of Hibernate Reverse Engineering creates a hibernate.reveng.xml file and also generates Hibernate Mapping XML files and POJO classes in Netbeans 6.5 release.

When a new project is created with Hibernate as a framework, a new hibernate.cfg.xml file is created with the appropriate information about Database Connection.

Now one can use the Hibernate mapping Files and POJOs from Database wizard to create hibernate.reveng.xml and also generate .hbm.xml and .java files.

From the File - New wizard, one can bring up the Hibernate mapping Files and POJOs from Database wizard. This wizard contains 4 panels.

The first panel gives you the file type to pick.


Selecting the Hibernate Reverse Engineering File type shows a brief description about it in the Description panel.

After selecting Hibernate Reverse Engineering File, press next button to bring up another wizard as shown below


This panel contains

  • File name, the name of the reverse engineering file. Here empty and uniqueness of the file are checked. I.e, if the
 file already exists or the name of the file is empty then an error message will be shown at the bottom of the 
 wizard panel.
  • Project, is a read only field, under which you want to create the configuration file.
  • Folder, by default set to src/java. But you can change the target folder by clicking the Browse button next to the
 text field to change the folder.
  • Created File, is a read only field, shows the location of the file.

Now press Next Button to select the database tables.....


This panel contains

  • Configuration File, is a drop down with a set of hibernate configuration files in a project.
  • Available Tables, is a list containing all the tables from a database connection defined in the configuration file.
 This list gets updated based on the selection of the configuration file.
  • Selected Tables, is a list. Using Add, Remove, AddAll and Remove All buttons one can update this list from the
 Available Tables.
Here select the Tables for which you want to generate POJOs and Mapping files.

Now press Next Button to select the generation of code options and also the package information.


This panel contains

  • General Settings, containing Java5 Syntax and EJB3 Annotations. Choosing EJB3 Annotations generate POJOs with annotations.
  • Code Generation Settings, by default both the check boxes for generating .hbm and .java are checked.
  • Project, is a read only field, under which you want to create .hbm and .java files.
  • Location, by default is set to Source packages.
  • Package, is a drop down. User must select the package to store the .hmb and .java files.

When the Finish button is pressed,

  • a new hibernate.reveng.xml file is created with the selected Tables information and placed under src/java.
  • hibernate mapping files and pojos are generated and placed under the package that the user selected in the fourth
  • hiberante.cfg.xml will be updated with the mapping information.

Hibernate Annotations support

In the 4th panel i.e Code Generation Panel, if the user picks just Domain Code (.java) with EJB3 annotations and without Hibernate XML Mapping (.hbm) then the wizard will generate POJOs with annotations and the configuration file will be updated with POJOs.

Hibernate Reverse Engineering Wizard Enhancements (targeted for 7.0)

  1. Create a separate wizard for Hibernate Reverse Engineering file creation.
  2. modify the existing wizard to pick a cfg.xml, reveng.xml and the exporters to generate POJOs and mapping files
  3. provide a context menu item on reveng.xml to invoke the same wizard to re generate the POJOs and mappings.
  4. provide an option to pick reverse engineering strategy if the user happen to have any (if time permits).

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo