生成Hibernate_sequence表 [英] Hibernate_sequence table is generated
问题描述
我有id列生成策略AUTO,我想知道,为什么MySql生成hibernate_sequence表?我认为hibernate将选择IDENTITY id生成策略
I have id column with generated strategy AUTO, I'm wondering, why MySql generate hibernate_sequence table? I supposed that hibernate will pick IDENTITY id generating strategy
<mapped-superclass class="com.cl.xlp.model.data.Identity">
<attributes>
<id name="id">
<column name="id" />
<generated-value strategy="AUTO" />
</id>
</attributes>
</mapped-superclass>
Hibernate属性
Hibernate properties
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto=update
Mysql连接器版本
Mysql connector version
version.mysql.connector>5.1.39</version.mysql.connector>
Mysql服务器版本是5.6.12
Mysql server version is 5.6.12
推荐答案
Hibernate解释自动生成类型的方式已经从Hibernate 5.0开始改变。
The way Hibernate interprets AUTO generation type has changed starting with Hibernate version 5.0.
当使用Hibernate v 4.0和Generation Type作为 AUTO
,特别是对于MySql,Hibernate会选择 IDENTITY
策略(因此使用 AUTO_INCREMENT
feature)用于为相关表生成ID。
When using Hibernate v 4.0 and Generation Type as AUTO
, specifically for MySql, Hibernate would choose the IDENTITY
strategy (and thus use the AUTO_INCREMENT
feature) for generating IDs for the table in question.
从版本5.0开始,当Generation Type被选为AUTO时,Hibernate使用 SequenceStyleGenerator
无论数据库如何。在MySql的情况下,Hibernate使用表模拟一个序列,这就是你看到hibernate_sequence表的原因。 MySql本身不支持标准序列类型。
Starting with version 5.0 when Generation Type is selected as AUTO, Hibernate uses SequenceStyleGenerator
regardless of the database. In case of MySql Hibernate emulates a sequence using a table and is why you are seeing the hibernate_sequence table. MySql doesn't support the standard sequence type natively.
引用
- < a href =http://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html#identifiers-generators-auto =noreferrer> http://docs.jboss.org/ hibernate / orm / 5.0 / userguide / html_single / Hibernate_User_Guide.html#identifierss- generators-auto
- https://www.thoughts-on-java.org/5-things-你需要知道什么时候使用hibernate-with-mysql /
- http://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html#identifiers-generators-auto
- https://www.thoughts-on-java.org/5-things-you-need-to-know-when-using-hibernate-with-mysql/
这篇关于生成Hibernate_sequence表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!