Generating Hibernate Mapping Files and POJOs from a Database

See Also

In addition to writing Hibernate mapping files and POJOs (Plain Old Java Objects) from scratch, you can also generate the mapping files and POJOs from a connected database with the Hibernate Mapping Files and POJOs from Database wizard.

To generate Hibernate mapping files and POJOs from a database:

  1. Right-click the project node in the Projects window and choose New > Other to open the New File wizard.
  2. In the New File wizard, select Hibernate Mapping Files and POJOs from Database from the Hibernate category.
  3. Specify the Folder where you want to save the generated hibernate.reveng reverse engineering file. Click Next.
  4. Select the Configuration File (hibernate.cfg.xml) from the drop down list.
  5. Select any tables in the Available Tables pane and click the Add to move the tables to the Selected Tables pane. Any tables related to the tables you select are automatically added to the list in the Selected Tables pane. The IDE will generate Hibernate mapping files and POJOs for each table listed in the Selected Tables pane.
  6. Click Next.
  7. Specify any options for the generated files.
  8. Select Domain Code to generate the POJOs.
  9. Select Hibernate XML Mappings to generate the mapping files.
  10. Select an existing package from the Package drop down list or type the name of a new package.
  11. Click Finish.

When you click Finish the IDE generates the following files:

See Also
Creating the Hibernate Configuration File
Editing the Hibernate Configuration File
Creating Hibernate Mapping Files
Adding Hibernate Support to a Project
About Hibernate Support
Connecting to a Database

Legal Notices