POJO Creation in NetBeans IDE after the creation the hibernate.revenge.xml file by R4R Team

Before creating the POJO class we need to create the hibernate.revenge.xml and hibernate.cfg.xml. If we done it then we can create the POJO class. Because POJO class when created till then we don't have the both xml file.

We can create the POJO class for this we need to Go in File Menu  Wizard-> select New file wizard -> search Hibernate and click Hibernate Mapping POJO class -> as shown in image and then press Next


 If we have both xml file (hibernate.cfg.xml and hibernate.revenge.xml) then we can create the POJO Class. It is mendatory. Mark on the JDK 5 feature 

 Always remember that POJO class having a perticular package to put. So we write the package name in package name option. and then Finish

When we click on the Finish that time two file will be create person.hbm.xml and  person.java as shown in the image.

 In the above image below code are shown in the editor of NetBeans.

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"


<!-- Generated 18 Oct, 2014 3:14:58 PM by Hibernate Tools 4.3.1 -->


    <class name="mypack.Person" table="person" catalog="hibernate_pro" optimistic-lock="version">

        <id name="id" type="java.lang.Integer">

            <column name="id" />

            <generator class="identity" />


        <property name="firstName" type="string">

            <column name="first_name" length="40" />


        <property name="lastName" type="string">

            <column name="last_name" length="40" />


        <property name="age" type="string">

            <column name="age" length="20" />


        <property name="profession" type="string">

            <column name="profession" length="15" />




This code shows the mapping with the database

In the above image which code are shown that are as below:

package mypack;

// Generated 18 Oct, 2014 3:14:58 PM by Hibernate Tools 4.3.1


 * Person generated by hbm2java


public class Person  implements java.io.Serializable {

     private Integer id;

     private String firstName;

     private String lastName;

     private String age;

     private String profession;

    public Person() {


    public Person(String firstName, String lastName, String age, String profession) {

       this.firstName = firstName;

       this.lastName = lastName;

       this.age = age;

       this.profession = profession;


    public Integer getId() {

        return this.id;


    public void setId(Integer id) {

        this.id = id;


    public String getFirstName() {

        return this.firstName;


    public void setFirstName(String firstName) {

        this.firstName = firstName;


    public String getLastName() {

        return this.lastName;


    public void setLastName(String lastName) {

        this.lastName = lastName;


    public String getAge() {

        return this.age;


    public void setAge(String age) {

        this.age = age;


    public String getProfession() {

        return this.profession;


    public void setProfession(String profession) {

        this.profession = profession;


Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!