JavaBean, POJO, VO, DTO, DAO 异同
2016-05-26 17:12
330 查看
refs:
https://dzone.com/articles/database-interaction-dao-and http://java-base.com/javabean-vs-dto-vs-pojo-jknb/
POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean,
EntityBean etc.) and does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks. This term was coined by Martin Fowler, Rebbecca Parsons and Josh MacKenzie who believed that by creating the acronym POJO,
such objects would have a “fancy name”, thereby convincing people that they were worthy of use.
JavaBean should provide default public constructor.
JavaBean should provide property accessor methods (getters and setters).
JavaBean should be serializable.
JavaBean is a example of POJO that is serializable, has a no-argument constructor, and allows access to properties using getter and setter methods that follow a simple naming convention.
immutable.
https://dzone.com/articles/database-interaction-dao-and http://java-base.com/javabean-vs-dto-vs-pojo-jknb/
Plain Old Java Object (POJO)
The name is used to emphasize that a given object is an ordinary Java Object, not a special object. It has absolutly no restrictions.POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean,
EntityBean etc.) and does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks. This term was coined by Martin Fowler, Rebbecca Parsons and Josh MacKenzie who believed that by creating the acronym POJO,
such objects would have a “fancy name”, thereby convincing people that they were worthy of use.
JavaBean
JavaBean is a simple java class or POJO, but with some restrictions. This is the main difference between a POJO and a JavaBean. Some of the restrictions are:JavaBean should provide default public constructor.
JavaBean should provide property accessor methods (getters and setters).
JavaBean should be serializable.
JavaBean is a example of POJO that is serializable, has a no-argument constructor, and allows access to properties using getter and setter methods that follow a simple naming convention.
Value Object (VO)
Value Object is simple object that holds values. The VO should be entirelyimmutable.
Data Transfer Object (DTO)
DTO is serializable object, which is used for transfering data between different processes. It shouldn’t be mixed with VO. This is exposed as design pattern.Data Access Object (DAO)
This is an object, which provides mechanism for accessing objects from the persistance layer. This is actually one of the most popular design patterns.相关文章推荐
- java动态代理
- Java中如何创建线程
- Lombok 安装、入门 - 消除冗长的 java 代码
- struts2中的类型转换
- 每天进步一点点--java多线程
- Spring mvc怎么获取当前应用的url地址?即jsp页面中的${contextpath}怎么得到?
- Good article about Java thread state
- 韩顺平Spring框架学习,学习笔记(十二)
- Spring事务管理回顾——基本概念
- 韩顺平Spring框架学习,学习笔记(十一)
- Java 匿名内部类
- Java通过Executors提供四种线程池
- RxJava变换操作符:.concatMap( )与.flatMap( )的比较
- Spring 与代理有关属性详解
- 深入理解Java中的接口
- 每天进步一点点--java连接mysql
- java追加写入Excel之新建工作薄
- Java的final关键字
- Java文件下载
- java string 初始化