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:
- Right-click the project node in the Projects window and choose New > Other to open the New File wizard.
- In the New File wizard, select Hibernate Mapping Files and POJOs from Database from the Hibernate category.
- Specify the Folder where you want to save the generated hibernate.reveng reverse engineering file. Click Next.
- Select the Configuration File (hibernate.cfg.xml) from the drop down list.
- The configuration file contains the database connection details.
If a connection to the database is not open you may be prompted to
supply a username and password to connect to the database.
The database must be running.
- 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.
- Click Next.
- Specify any options for the generated files.
- Select Domain Code to generate the POJOs.
- Select Hibernate XML Mappings to generate the mapping files.
- Select an existing package from the Package drop down list or type the name of a new package.
- Click Finish.
When you click Finish the IDE generates the following files:
- POJOs based on the selected specified tables (if you selected Domain Code in the wizard)
- Hibernate mapping files based on the specified tables (if you selected Hibernate XML Mappings in the wizard)
- A hibernate.reveng reverse engineering file in the specified location
- 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