The difference between Pojo and JavaBean

Source: Internet
Author: User

POJO (Plain ordinary Java Object) A simple Java objectThe actual is the ordinary JavaBeansTo avoid the short name created by the confusion with EJBS. The Pojo name is used to avoid confusion with EJBS, and the abbreviation is more straightforward. Some of these properties and their getter, setter method classes, have no business logic, and can sometimes be used as VO (value-object) or DTO (Data Transform object). Of course, if you have a simple arithmetic attribute is also possible,     However, there are no business methods, nor can we carry methods such as connection. Pojo objects are sometimes referred to as data objects, and are used in large numbers to represent objects in reality. If the hibernate framework is used in the project, there is an associated XML file that corresponds to the table in the database, and the properties of the object correspond to the fields in the table. POJO and JavaBeanIs our common two keywords, generally easy to confuse, Pojo full name is plain ordinary Java object/pure old Java Object, Chinese can be translated into: Ordinary Java class, with a part getter/ The class of setter methods can be called Pojo, but JavaBean is much more complex than Pojo, Java beans are reusable components, there is no strict specification for Java beans, and in theory, any Java class can be a Bean. In general, however, because Java beans are created by containers (such as Tomcat), Java beans should have a parameterless constructor, and in addition, Java beans typically implement the Serializable interface to implement Bean persistence. Java beans cannot be accessed across processes. JavaBean is a component technology, as if you have made a wrench, and this wrench will be used in many places, this wrench also provides a variety of functions (you can take this wrench wrench, hammer, pry, etc.), and this wrench is a component. in general, when building a database mapping object in a Web application, we can only call it Pojo. POJO (Plain old Java object) this name is used to emphasize that it is an ordinary Java object, not a special object, which is primarily used to refer to Java objects that do not conform to a particular Java object Model, Convention, or framework (such as EJB).    Ideally, a pojo is a Java object that is not subject to any restrictions (except the Java language Specification). Pojo is a simple generic Java object that does not contain business logic or persistent logic, but is not javabean, Entitybean, etc., and does not have any special roles and classes or interfaces that do not inherit or implement any other Java framework.

The difference between Pojo and JavaBean

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.