Creating Hibernate Mapping Files
See Also
Hibernate mapping files are XML files that contain object relational mapping (ORM) data that Hibernate
uses to determine how classes are mapped to table columns and primary keys.
You can use the following wizards to generate Hibernate mapping files:
- Hibernate Mapping Wizard.
This wizard generates a single mapping file for a specified class.
After you create the mapping file you need to edit the mapping file
in the XML editor to map the fields in the class to the corresponding columns in the table.
You can use the IDE's code completion feature to help you edit the mapping file.
- Hibernate Mapping Files and POJOs from Database.
If you use this wizard you can set the option for the IDE to automatically generate
Hibernate mapping files for the tables you select in the wizard.
The wizard automatically modifies the Hibernate configuration file
to specify the Hibernate mapping files.
To create a Hibernate mapping file for a class:
- Right-click the package node containing the class to be mapped and choose New > Other to open the New File wizard.
- Select Hibernate from the Categories list and Hibernate Mapping Wizard from the File Types list. Click Next.
- Type <CLASS_NAME>.hbm for the file name, where <CLASS_NAME>
is the name of the class that you want to map. Click Next.
- Specify the Class that you want to map to a table.
You can click the button to locate the class.
- Choose the corresponding database table from the drop down list.
Click Finish.
When you click Finish, the mapping file is created in the source package you specified
and the file opens in the Source Editor.
The Hibernate configuration file is modified to specify the mapping file.
- See Also
- Creating the Hibernate Configuration File
- Editing the Hibernate Configuration File
- Adding Hibernate Support to a Project
- About Hibernate Support
Legal Notices