我有一个使用 spring 数据/jpa 的 SpringBoot 2.0.1.RELEASE 应用程序
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
但是当我在 Amazon Aurora 数据库中进行更新时,出现了这个错误:
2018-04-13 09:20 [pool-1-thread-1] 错误 ohid.enhanced.TableStructure.execute(148) - 无法读取高值 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘elbar .hibernate_sequence’ 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 中不存在
我在我要保存的实体中有这个
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
我也想避免数据库中获取 ID 的任何缺点。
原文由 en Peris 发布,翻译遵循 CC BY-SA 4.0 许可协议
随着生成
GenerationType.AUTO
hibernate 将查找默认值hibernate_sequence
表,因此将生成更改为IDENTITY
如下所示