Java JpaSystemException:无法读取hi值-您需要填充表:
我有web jpa项目,我的项目来自postgres和mysql数据库,但当我在mysql数据库中添加新数据时,我得到异常:Java JpaSystemException:无法读取hi值-您需要填充表:,java,spring-mvc,spring-data,Java,Spring Mvc,Spring Data,我有web jpa项目,我的项目来自postgres和mysql数据库,但当我在mysql数据库中添加新数据时,我得到异常: HTTP Status 500 - Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not read a hi value - you need to populate the table: hibernate_sequ
HTTP Status 500 - Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not read a hi value - you need to populate the table: hibernate_sequence; nested exception is org.hibernate.id.IdentifierGenerationException: could not read a hi value - you need to populate the table: hibernate_sequence
ERROR [http-nio-8080-exec-5] <unknown>.<unknown> could not read a hi value - you need to populate the table: hibernate_sequence
这是我的实体类:
用户
@Entity
@Table(name = "USERS_TABLE")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "USERS_NAME")
private String name;
@Column(name = "USERS_EMAIL")
private String email;
}
UserKey
@Entity
@Table(name = "USERS_KEY")
public class UserKey {
@Id
@GeneratedValue
private Long id;
@Column(name = "KEY_COLUMN")
private int key;
@OneToOne
@JoinColumn(name = "USERS_ID")
private User user;
}
问题解决了,需要添加
insert到mysqldb中。hibernate_序列(next_val)值(0)
我将推荐insert到hibernate_序列(next_val)值(1)代码>插入0似乎会导致我出现意外行为。我不知道为什么会发生这种情况,但value0
会导致第一次repo.save()
触发两次。
@Entity
@Table(name = "USERS_KEY")
public class UserKey {
@Id
@GeneratedValue
private Long id;
@Column(name = "KEY_COLUMN")
private int key;
@OneToOne
@JoinColumn(name = "USERS_ID")
private User user;
}