我有一个使用 spring data / jpa 的 Spring Boot 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] 错误 o.h.id.enhanced.TableStructure.execute(148) - 无法读取 hi 值
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:表'elbar.hibernate_sequence'在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)中不存在
我在我想要保存的实体中有这个
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
我想避免数据库中获取 ID 的任何缺点。
随着一代GenerationType.AUTO
hibernate将寻找默认值hibernate_sequence
表 ,因此将 Generation 更改为IDENTITY
如下 :
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)