Get all updates of Java4s
Follow Us: Email Newsletter

Simple Hibernate Application Requirements

Hibernate » On May 13, 2011 { 15 Comments } By Sivateja

Any hibernate application, for example consider even first hello world program must always contains 4 files totally.

  • POJO class
  • Mapping XML
  • Configuration XML
  • One java file to write our logic

Actually these are the minimum requirement to run any hibernate application, and in fact we may require any number of POJO classes and any number of mapping xml files (Number of POJO classes = that many number of mapping xmls), and only one configuration xml and finally one java file to write our logic.

POJO Class:

  • POJO is a simple java file, no need to extend any class or implement any interface.
  • This POJO class contain private properties variables, and for each property a setter and a getter



Mapping xml For POJO:

Here is the mapping file related to above pojo class, if you have any doubts on the syntax of the Mapping xml file, you can check our previous session

Yes., see in this above mapping xml, for stAddress property i have not written any column name i just been specified  <property name=”stAddress “/>, this means in the database the column name for stAddress property will also be stAddress, in these cases we can ignore the column attribute to write, and i will explain about this <generator /> element later.


Configuration XML

Usually configuration file name will be hibernate.cfg.xml

You Might Also Like

  ♦ About Author ♦

Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.


15 Responses to “Simple Hibernate Application Requirements”
  1. Pavan says:

    Sir,can u explain about the POJO class i.e., why should the properties be private always and why getters and setters public …have some confusion about it…

  2. Java4s says:


    Hi pavan, its really good question.

    We used to take instance variables as private, and methods as public because of security.

    If you would like to ask these type of questions, please post the questions at ‘‘ so that we will be able to answer you with some simple examples if possible.

  3. chakradhar says:

    Good Work Svateja….But we need some more related to real time examples…i suggest you to take some examples what we are commonly using in Max of the real time applications.Post that type of real time examples in your blog.That will helpful for you and every one.


  4. ravi says:

    how spring reduces boilerplate code ?

  5. Rajasekhar says:

    Hi Siva Teja,

    As you said that we can implement / extend any class or interface in pojo/entity class but in newer version of hibernate why we implement the serialize interface in every hibernate entity class , is there any particular reason behind this..? are there any dis advantages if don’t implement serialize interface?
    If you answer for this question it’s helpful to me.
    thank you very mnuch

  6. Arun Singh says:

    thnks sir

  7. Annonymous says:

    Hi Rajsekhar.. I think we implement serializable interface with some specific entity/pojo class while we have a requirement of composite primary key in our project ,at that time only we serialize our entiry class and provide a tag in our mapping file either, But i’ve no exact idea that, why there is a requirement of serialization :P

  8. k.ravindhar says:

    hai rajashekar,

    we are implementing interface serialization why because in hibernate directly hibernate column values stored directly.cannot convert into text like jdbc.serialization means stream format it can any format

  9. Beginner says:

    Is internet connection must for running Hibernate application using Eclipse?

  10. yamini says:

    it is very useful thank you so much but give brief explanation

  11. balamurugan says:

    Simply explained. I Like it

  12. Rajesh says:

    Hi teja,
    can you please explain me, how can we provide security by using encapsulation using private variables

  13. Susmitha says:

    If i use mysql Datebase what are the changes required in the configuration file

  14. saroj kumar says:

    what is pojo class

  15. GopiKolli says:

    Sir,can u explain about the POJO class i.e., why should the properties be private always and why getters and setters public …have some confusion about it


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.