Hibernate annotation (annoation) generate policy using ID primary key

Source: Internet
Author: User

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)

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.