POJOs

What are POJOs?
How POJOs are created & used in Hibernate?

Questions by swap_j2ee

Showing Answers 1 - 9 of 9 Answers

You can use the Hibernate Mapping Files and POJOs from a Database wizard to generate files for you. The wizard can generate a POJO and a corresponding mapping file for each table that you select in the wizard. The mapping files are XML files that contain data about how the columns in the tables are mapped to the fields in the POJOs. You need to have the hibernate.reveng.xml and hibernate.cfg.xml files to use the wizard.

To create the POJOS and mapping files using a wizard, perform the following steps.

  1. Right-click the Source Packages node in the Projects window and choose New > Other to open the New File wizard.
  2. Select Hibernate Mapping Files and POJOs from a Database in the Hibernate category. Click Next.
  3. Ensure that the hibernate.cfg.xml and hibernate.reveng.xml files are selected in the drop down lists.
  4. Select JDK 5 Language Features under the General Settings options.
  5. Ensure that the Domain Code and Hibernate XML Mappings options are selected.
  6. Select  the Package name. Click Finish.

  Was this answer useful?  Yes

Thomas John

  • Sep 21st, 2015
 

A Java Bean is a Java class that has getters and setters in order to conform to Java-bean standards. Essentially you declare properties private and use getters and setters to read or modify the data. The standardization was introduced to enable automatic access to properties via Java reflection to automate some activity performed e.g. by application servers.

A POJO is a "plain old java object" hence and instance of a simple java class. Decoupling the application code from the infrastructure frameworks is one of the many benefits of using POJOs. In hibernate POJO has 3 states - Transient state, Persistent state and Detached state.

The Hibernate POJO Generator produces all the Java code necessary to access each field in each table via the Hibernate persistence framework. Given a source database, Hibernate POJO Generator (hbnPojoGen) generates:

Java objects representing each table using annotations for use with Hibernate.

A JUnit test case per table that uses the objects generated to create, populate, save, retrieve and compare results
DAO per class
The appropriate enumeration files
Spring and hibernate configuration
DAO layers

A data factory class per schema to return a pre-populated object with random data (for boundary checking, database population, etc)

  Was this answer useful?  Yes

bhaskar daggupati

  • Nov 7th, 2017
 

POJO class did happened in Hibernate...when we are doing reverse engineering to the project at that time it will be happened. POJO class will be used setters nd getters to insert or retrive the data.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions