问题描述
状态
但我无法找到文档/概述@GeneratedValue策略用于定义特定数据库作为GenerationType.AUTO。
But I'm unable to find a documentation/overview what @GeneratedValue strategy is used for the specific databases when defining them as GenerationType.AUTO.
有人知道是否有人维护主要数据库(例如Oracle,DB2,PostgreSQL,MySQL,MSSQL)的实际生成策略的列表。 ..)?
Does anybody know whether someone maintains a list of the actual generation strategy for the major databases (e.g. Oracle, DB2, PostgreSQL, MySQL, MSSQL, ...)? And where to find it?
推荐答案
此链接关于Java Persistence API,并且定期更新。
This link is about Java Persistence API and seems regularly updated.http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing
序列对象使用特殊的数据库对象来生成id。
仅在某些数据库中支持序列对象,例如 Oracle,
DB2和Postgres 。通常,SEQUENCE对象具有名称,
INCREMENT和其他数据库对象设置。每次选择
.NEXTVAL时,序列都会被
INCREMENT增加。
Sequence objects use special database objects to generate ids. Sequence objects are only supported in some databases, such as Oracle, DB2, and Postgres. Usually, a SEQUENCE object has a name, an INCREMENT, and other database object settings. Each time the .NEXTVAL is selected the sequence is incremented by the INCREMENT.
如果数据库(如DB2)支持IDENTITY列,而序列hibernate选择Identity列,请参阅:
If the database such as DB2 supports both IDENTITY columns and Sequences hibernate chooses Identity columns, see Dialect:
public Class getNativeIdentifierGeneratorClass() {
if ( supportsIdentityColumns() ) {
return IdentityGenerator.class;
}
else if ( supportsSequences() ) {
return SequenceGenerator.class;
}
else {
return TableHiLoGenerator.class;
}
}
您可以检查supportsIdentityColumns通过查看包。
You can check what is returned from supportsIdentityColumns() and supportsSequences() for each database by looking at the relevant dialect in the org.hibernate.dialect
package.
这篇关于为“GenerationType.AUTO”实际选择了什么策略为主要数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!