Hibernate-common attributes in the class ing file. We add User. hbm. xml to some extensions to illustrate the meaning of common attributes:
Hibernate-common attributes in the class ing file. We add User. hbm. xml to some extensions to illustrate the meaning of common attributes:
We add User. hbm. xml to some extensions to illustrate the meanings of common attributes:
The column attribute is not specified here, indicating that it is the same as the name value.
Length = "20" if the length of the value submitted by the foreground exceeds 20, Hibernate will throw an exception
Not-null = "true" if the value submitted by the front-end is null, Hibernate will throw an exception
Unique = "true" if the value submitted by the front-end already exists in the data, Hibernate throws an exception (Hibernate automatically determines whether duplicate data exists in the Database)
Update = "false" indicates that this field is not involved in the update operation (Hibernate will not generate the SQL statement for this field)
Insert = "true" indicates that this field is used in the insert operation.
You can change it to the following representation.
Is the primary key generation policy, which is automatically generated by Hibernate.
Here we will explain the concepts of proxy primary keys and business primary keys.
The proxy primary key is a record that is not related to the business and can uniquely identify the database. Generally, it is automatically generated by the database. For example, mysql can use auto_increment and Sql2000 can use identity generation, oracle can use sequence generation
A business primary key is a business-related service that is specified by the user and uniquely identifies any record in the database. It is also called a natural primary key.
Hibernate can help generate business primary keys
This is a generation method. Next I will explain in detail how to generate the business primary key in hibernate:
Increment: generates the OID in ascending mode. Each time you add 1
Identiry: OID generated by the underlying database, provided that the database supports automatically adding fields
Sequence: hibernate generates OID Based on the sequence of the underlying database, provided that the database supports the sequence
Hilo: generates OID based on the high/low algorithm. Hibernate uses the field of the table to be determined as the high value. By default, the next_hi value of the hibernate_unique_key table is used.
Seqhilo: the appearance of hibernate3.0. A primary key is generated based on the high-bit algorithm, and a sequence is required.
Native: automatically selects the OID generation method based on the database situation
Uuid. hex: uses the 128-bit uuid algorithm to generate the OID, which occupies a large space.
Assigned: a primary key generated by a JAVA application. It is applicable to natural primary keys.