Hibernate Persistence principles

Source: Internet
Author: User

Hibernate Persistence principles
Persistence java classes must follow the following principles:
1. This class usually requires an id. We recommend that you use the encapsulation type.
2. This class cannot be modified by final.
3. You need to provide a non-parameter constructor for this class.
4. The getter/setter method must be provided for all attributes.
5. If operations on the set data are involved, use the interface type, List, Map
Hibernate Persistence problems: what conditions must be met for attributes in the hibernate Persistence class so that hibernate can be persisted for them?

No

You do not understand the core of hibernate Persistence
First, The hibernate Persistence class must first comply with the javabean specification.
Private property
Public get and set methods
Serialization Interface

Of course, this is only a specification. In fact, if you do not declare the access permission of an attribute, you can still persist this class because the javabean specification is only a specification.

The core of the hibernate Persistence class is to map fields and attributes. As long as you have configured the ing relationship between fields and attributes in the hibernate ing file, as long as the object class has set and get, as long as this object and Session the relationship will be persistent.

In hibernate, the persistence class is different from that in javabean.

In hibernate, persistence classes are the embodiment of tables in the database. fields correspond to tables one by one, and the persistence classes of associated tables are included.

Persistence class is generally called PO

In fact, PO is a type of javabean. The so-called javabean is a simple object used to load data in java. In addition to being used as a database entity, the javabean can also be used to store data, transmit data, and display data on the foreground, A simple javabean generally only has a bunch of private attributes and a bunch of get set methods.

Related Article

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.