POJO & JavaBean division

concept

  • POJO (Plain Old Java Object) : ordinary Java class, the intrinsic meaning of POJO refers to those java objects that do not inherit from any class, do not implement any interface, and are not invaded by other frameworks;

  • JavaBean : javaBean is a reusable component written in Java language. To be written as a JavaBean, a class must be concrete and public, and have a parameterless constructor. JavaBeans expose member properties from internal fields by providing public methods that conform to consistent design patterns. More of a specification, a java object that contains a set of set and get methods. javaBean can make applications more object-oriented, encapsulate data, separate application business logic and display logic, and reduce development complexity and maintenance costs

  • entity : entity bean, generally used for ORM object relationship mapping, an entity is mapped into a table, generally no business logic code

JavaBean Specification

  • All attributes are private;
  • This class must have a public default constructor. That is, a constructor with no parameters is provided;
  • The properties of this class are accessed using getters and setters, and other methods follow standard naming conventions;
  • This class should be serializable. Implement serializable interface;

POJO & JavaBean division

  • POJOs are actually simpler classes or interfaces that are purer than javabeans. POJO strictly adheres to the concept of simple objects, and some JavaBeans often encapsulate some simple logic.
  • POJO is mainly used for temporary transfer of data, it can only load data, as the carrier of data storage, without the ability to process business logic.
  • Although the data acquisition of Javabean is the same as that of POJO, there can be other methods in Javabean.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325673296&siteId=291194637