简体   繁体   中英

What is the difference between POJO and DAO

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

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.

Term is already easy to understand. It is Design pattern. if you agree it, you can use. Otherwise, you cannot.

As you mention

POJO is Plain old java object which take responsibility to keep the data, not business processing.

DAO is Data access object which take responsibility to process persistence/database processing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM