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.
- Select the Configuration File (hibernate.cfg.xml) and
Reverse Engineering File (hibernate.reveng) from the dropdown lists.
- 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.
- Specify any General Settings 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
- Creating a Hibernate Reverse Engineering 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