First, the JPA generic policy generator
With annotation to map hibernate entities, the annotation-based Hibernate primary key is identified as @id,
The generation rules are set by @generatedvalue. The @id and @generatedvalue here are the standard uses of JPA,
JPA provides four standard usages, which can be clearly seen by the @generatedvalue source code.
Java code public enum generationtype{TABLE, SEQUENCE, IDENTITY, AUTO}
The four standard usages provided by JPA are table,sequence,identity,auto.
Table: Use a specific database table to hold the primary key.
SEQUENCE: Generates a primary key based on the sequence of the underlying database, provided the database supports the sequence.
IDENTITY: Primary key is automatically generated by the database (mainly auto-growth type)
AUTO: The primary key is controlled by the program.
This applies the table tb_generator, defined as
SQL code CREATE TABLE tb_generator (ID number not NULL, Gen_name VARCHAR2 (255) isn't null, gen_value number not NULL, PRIMARY KEY (ID))
Insert record for generating primary key to use,
SQL code INSERT into tb_generator (ID, gen_name, gen_value) VALUES (1,PAYABLEMOENY_PK ', 1);
After the primary key is generated, the value of this record is incremented by Allocationsize.
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.