Par*_*nin 4 java spring hibernate spring-mvc
为什么我得到
引起:org.hibernate.MappingException:无法实例化 id 生成器 [entity-name=hw11.model.domain.Client]?
这里是类 Client 这里是一个错误所在的类
我的代码是这样的:
...
@Id
@Column(name = "ID")
@SequenceGenerator(name = "stu_seq", sequenceName = "STUDENT_SEQ", allocationSize = 10)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "stu_seq")
private int id;
...
Run Code Online (Sandbox Code Playgroud)
我只是将其设置allocationSize为 1 并解决了问题。
它说了你需要知道的一切:
org.hibernate.dialect.MySQLDialect does not support sequences
Run Code Online (Sandbox Code Playgroud)
使用 MySQL 时不要使用序列。您可能有一些具有id如下定义的实体:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "your_seq")
private Long id;
Run Code Online (Sandbox Code Playgroud)
将它们替换为以下代码以使用 MySQL 的Auto Increment功能:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15852 次 |
| 最近记录: |