Persistent object uniquely identifies--oid
1) The primary key in the database can be used to distinguish whether two objects are the same
2) Whether the memory address of the object used in the Java language distinguishes between objects
3) Use OID in Hibernate to distinguish objects from the same
Hibernate considers that each of the different objects should have a unique identifier, which is called the OID;
In order to make the data model use the same primary key as the database table to differentiate the data, declare the unique identity (UUID) in the data Model class as the unique identifier of the Hibernate management object, and use the identity to correspond with the primary key in the database table one by one;
To tie in with the use of later frames, this identity is also used to set the rules for Java object differentiation, which is to generate hashcode and equals methods with reference to this property.
Selection rules for OID
1) You can use any attribute as an OID in a Java object, why use the UUID as a unique identifier
2) Natural PRIMARY key: has business meaning
For example, the identity card number in personal information is not only unique, but also has business meaning, although it can be used as OID, but it has some business meaning. Select OID to avoid using properties with business implications
3) Proxy primary key: does not have business meaning
Declares a property that does not have any business meaning and is used only to differentiate objects, which are not a security hazard even if they are viewed by the end user.
4) OID selection should try to avoid using the natural primary key, instead of the proxy primary key
Hibernate Framework Learning Persistence Object OID