在执行插入操作时,我得到"ERROR: Relation关系“hibernate_sequence不存在”异常“。
Technical Stack
-> Springboot
-> Hibernate
-> PostgreSQL
Approaches tried so far.
-> Verified all entity classes in project, generation strategy is used as "@GeneratedValue(strategy = GenerationType.IDENTITY)".
-> Verified database tables, pk is either Serial or Int with proper sequence generated value.
-> Tried with use-new-id-generator-mappings property as false, didn't worked.
-> Verified sequence with name "hibernate_sequence" is available in Database.
Analysis so far
-> Entities those are annotated with @Audited having this issue as hibernate envers expect global "hibernate_sequence". But not able to find the exact solution.
Note : This was working few days back without any issue, Since last week started getting this issue.发布于 2022-01-15 13:47:35
正如您所说,hibernate-envers正在寻找hibernate_sequence。
它用于将记录插入REVINFO表中。
假设spring.jpa.hibernate.ddl-auto未设置为create
任一
manually
rev_id_seq。然后,通过添加RevisionEntity的定义,重写REVINFO定义以更改序列名称
@Entity
@RevisionEntity
public class MyRevision implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rev_id_generator")
@SequenceGenerator(name = "rev_id_generator", sequenceName = "rev_id_seq", allocationSize = 1)
@RevisionNumber
private int id;
@RevisionTimestamp
private long timestamp;
// Getters, setters, equals, hashCode ...
}https://thorben-janssen.com/hibernate-envers-extend-standard-revision/
发布于 2022-01-16 07:06:42
最初,将spring.jpa.hibernate.ddl-auto设置为首次创建并运行应用程序。它将创建hibernate序列。在此之后,spring.jpa.hibernate.ddl-auto改为none。它将防止表中任何进一步的数据丢失。如果需要,也可以将其设置为更新。
发布于 2022-08-16 15:25:49
因为您正在使用@GeneratedValue()
它将查找正在使用的数据库如何生成It。对于MySql或HSQSL,有自动递增的增量字段。在Postgres或Oracle中,它们使用序列表。因为您没有指定序列表名,所以它将查找名为hibernate_sequence的序列表,并默认使用它。因此,您可能在数据库中没有这样的序列表,现在您得到了该错误。
我也得到了这个工作使用;
@GeneratedValue(strategy = GenerationType.IDENTITY)https://stackoverflow.com/questions/70679748
复制相似问题