The hibernate annotation (annoation) uses the Id primary key to generate the main use of the following annotations: @Id, @GeneratedValue, @GenericGenerator. , the @GeneratedValue is the JPA default implementation custom primary key generation strategy, @GenericGenerator is hibernate based on the JPA enhancements.
Custom primary key generation policy, implemented by @genericgenerator. Hibernate is extended on the basis of JPA, and it can be used to introduce Hibernate's unique primary key generation strategy, which is joined by @genericgenerator.
For example, JPA standard usage
1 2 |
@Id @GeneratedValue (Generationtype.auto) |
You can use Hibernate to implement the following usage
1 2 3 |
@GeneratedValue (strategy = Generationtype.auto) @GenericGenerator (name = "Paymentablegenerator", strategy = "native") |
Using @generatedvalue
1, for the Mysql,oracle,sqlserver database can be used at the same time
1 2 3 |
@Id @GeneratedValue (strategy = Generationtype.auto) |