What is the difference between POJO and DAO

Rajesh Kumar picture Rajesh Kumar · Aug 12, 2014 · Viewed 10.2k times · Source

May I know what is the difference between POJO (Plain old java object) and DAO (Data access object) in Java.

Where to use which one?

From the Jboss hibernate tutorial (http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch04.html#persistent-classes-pojo), why POJO is used with database if we have DAO?

Thanks in advance

Answer

Svante picture Svante · Aug 12, 2014

In Java parlance, a DAO is an organizing class that contains methods to access a database table. A POJO holds database records. A DAO will return POJOs from some of its methods.