Hibernate各种主键生成策略与配置详解(国外英文资料).docVIP

  • 12
  • 0
  • 约1.31万字
  • 约 20页
  • 2017-07-05 发布于河南
  • 举报

Hibernate各种主键生成策略与配置详解(国外英文资料).doc

Hibernate各种主键生成策略与配置详解(国外英文资料)

Hibernate各种主键生成策略与配置详解 Hibernate various primary key generation strategies and configuration detail Catalog Hibernate various key generation strategies and configuration details 1 1, assigned 2 2, increment 2 3, Hilo 2 4, seqhilo 3 5, sequence 3 6, identity 3 7, native 3 8, UUID 3 9, guid 3 10, foreign 3 11, select 3 12, other notes, configuration 3 13 summary 3 1, assigned The primary key is generated by an external program and must be specified before save (). Hibernate is not responsible for maintaining primary key generation. Unrelated to Hibernate and the underlying database, you can cross databases. Before storing objects, you must assign the primary key to the primary key using the setter method, and how this value is generated is entirely up to you, and this approach should be avoided as much as possible. id name=, Id, column=, Id generator class= assigned / /id Comment mode @Id @GeneratedValue (generator = ` UD ) @GenericGenerator (name = ` UD , strategy = ` assigned) UD is a custom policy name, a human name, followed by UD. Features: cross database, artificial control, primary key generation, should be avoided as far as possible. 2, increment The maximum value is Hibernate out of the database of the key (each session only take 1 times), on the basis of the value of each, in increments of 1, generating primary key in memory, do not depend on the underlying database, so we can cross database. id name=, Id, column=, Id generator class= increment / /id Hibernate calls the generate () method inside the org.hibernate.id.IncrementGenerator class and uses the select max (idColumnName) from tableName statement to obtain the primary key maximum. The method is declared as synchronized, however, so in a Java virtual machine internal independence is not a problem, and access to the database select max on multiple concurrent JVM could remove the same value, then insert will happen Dumplicate entry error. So there is only one Hibernate application process to access t

文档评论(0)

1亿VIP精品文档

相关文档