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.