Hibernate Framework Learning Persistence Object OID

Source: Internet
Author: User
Tags uuid

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

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.