Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate_sequence does not exist with hibernate envers

Tags:

java

hibernate

I am using Hibernate Envers with entity

@Entity
@Table(name = "users", schema = "core")
@Audited public class Users implements java.io.Serializable, Comparable<Users> {
    protected static final long serialVersionUID = 1250157348010696249L;    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "userid")
    protected Integer userId;

    @Column(name = "aduserid")
    protected String aduserId;

    @Column(name = "firstname")
    protected String firstName;

    @Column(name = "middlename")

i am getting error hibernate sequence does not exist .

when i am changing false then it says revision generator does not exist. Pls help me.

like image 585
user3460330 Avatar asked Nov 12 '15 14:11

user3460330


People also ask

How hibernate envers works?

Hibernate Envers provides a very simple solution for CDC (Change Data Capture). It uses the Hibernate Event system to intercept all entity state transitions and audit them. The database transaction will roll back and both the actual changes and the audit log is rolled back.

What is envers?

The Envers module is a core Hibernate model that works both with Hibernate and JPA. In fact, you can use Envers anywhere Hibernate works whether that is standalone, inside WildFly or JBoss AS, Spring, Grails, etc. The Envers module aims to provide an easy auditing / versioning solution for entity classes.

What is Hibernate_sequence table?

If you use strategy="AUTO" , Hibernate will generate a table called hibernate_sequence to provide the next number for the ID sequence. You may have forgotten to add the AutoIncrement feature to your table's PK.


2 Answers

you need to create hibernate_sequence in your database, check sample code

CREATE SEQUENCE hibernate_sequence  INCREMENT 1  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
like image 132
Sangram Badi Avatar answered Nov 07 '22 20:11

Sangram Badi


Hibernate Envers expects a global sequence "hibernate_sequence" in order to insert into the "revinfo" table.

like image 22
Jean-Christophe Avatar answered Nov 07 '22 19:11

Jean-Christophe