Following note is extracted from netbeans Tutotial,
In this tutorial you use a POJO (plain old Java object) to represent the data in each of the tables in the database that you will use. The Java class specifies the fields for the columns in the tables and uses simple setters and getters to retrieve and write the data. To map the POJOs to the tables you can use a Hibernate mapping file or use annotations in the class.
You can use the Hibernate Mapping Files and POJOs from a Database wizard to create multiple POJOs and mapping files based on database tables. When you use the wizard you select all the tables for which you want POJOs and mapping files and the IDE then generates the files for you based on the database tables and adds the mapping entries to hibernate.cfg.xml. When you use the wizard you can choose the files that you want the IDE to generate (only the POJOs, for example) and select code generation options (generate code that uses EJB 3 annotations, for example).
Note. The IDE also has wizards to help you create individual POJOs and mapping files from scratch.
- Right-click the Source Packages node in the Projects window and choose New > Other to open the New File wizard.
- Select Hibernate Mapping Files and POJOs from a Database in the Hibernate category. Click Next.
- Keep the default values in the Name and Location pane. Click Next.
- Select hibernate.cfg.xml from the Configuration File drop down list, if not selected.
- Select the from Available Tables and click Add to add the tables to Selected Tables.
No comments:
Post a Comment