8

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.

Ritesh
  • 7,322
  • 2
  • 38
  • 42
user3460330
  • 125
  • 3
  • 10
  • Please format your question properbly – Jens Nov 12 '15 at 14:27
  • Use a hbm2ddl export, create the script and check the `CREATE` statements have been run on your database. Maybe just use the script as-is in a fresh empty database ? http://stackoverflow.com/questions/438146/hibernate-hbm2ddl-auto-possible-values-and-what-they-do ... you probably need the hibernate_sequence table that will get created in the script if it is needed. What database you use? – Darryl Miles Nov 12 '15 at 14:30
  • 1
    Was the issue identified? Could you please post your fix? I am evaluating using hibernate-envers and having this same issue when I add the @Audited annotation to the entity class. – SGB Oct 24 '16 at 17:00

2 Answers2

10

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;
Sangram Badi
  • 3,886
  • 6
  • 36
  • 69
  • Is this the case with every DB ? I remember using envers with an SQL Server DB and there I created no explicit sequence (or I am not able to find it in the project's code). – Tchypp Jul 26 '21 at 06:59
4

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

Jean-Christophe
  • 574
  • 4
  • 10