Difference between DTO, VO, POJO, JavaBeans?

后端 未结 7 1876
误落风尘
误落风尘 2020-11-22 07:46

Have seen some similar questions:

  • What is the difference between a JavaBean and a POJO?
  • What is the Difference Between POJO (Plain Old Java Object) an
7条回答
  •  日久生厌
    2020-11-22 08:15

    Java Beans are not the same thing as EJBs.

    The JavaBeans specification in Java 1.0 was Sun's attempt to allow Java objects to be manipulated in an IDE that looked like VB. There were rules laid down for objects that qualified as "Java Beans":

    1. Default constructor
    2. Getters and setters for private data members that followed the proper naming convention
    3. Serializable
    4. Maybe others that I'm forgetting.

    EJBs came later. They combine distributed components and a transactional model, running in a container that manages threads, pooling, life cycle, and provides services. They are a far cry from Java Beans.

    DTOs came about in the Java context because people found out that the EJB 1.0 spec was too "chatty" with the database. Rather than make a roundtrip for every data element, people would package them into Java Beans in bulk and ship them around.

    POJOs were a reaction against EJBs.

提交回复
热议问题