Generator configuration method of Hibernate mapping file ID
The optional < generator > child element is the name of a Java class, which is used to generate a unique identifier of the persistent class instance. If the generator instance needs some configuration values or initialization parameters, you can use the < param > element to pass these parameters.
All generators implement org hibernate. Id.identifiergenerator interface. This is a very simple interface; Some applications can choose to provide their own specific implementations. Of course, hibernate provides many built-in implementations.
Here are some quick names of built-in generators:
Increment
Used to generate unique identifiers for long, short, or int types. It can only be used when no other process inserts data into the same table. Do not use it under the cluster.
Identity
Supports the built-in identification fields of DB2, mysql, MS SQL server, Sybase and hypersonic SQL. The returned identifier is of type long, short or int.
Sequence
Sequences are used in DB2, PostgreSQL, Oracle, SAP dB, and mckoi, while generators are used in InterBase. The returned identifier is of type long, short or int.
Assigned
The primary key is generated by an external program without the participation of hibernate, which allows the application to assign an identifier to the object before the save () method is called. This is the default generation policy when the < generator > element is not specified.
The above hibernate mapping file ID generator configuration method is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.