3 Replies Latest reply on Jan 30, 2013 3:57 PM by Adam Warski

    Single Revision for Multiple Schemas

    sebp Newbie

      I have a database with multiple schemas and I want to have a single, global revision. Therefore I defined the revision entity as follows:


      @Entity(name = "Revision")
      @Table(name = "revision", schema = "space")
      @SequenceGenerator(name = "RevisionSequence", sequenceName = "space.seq_revision", initialValue = 1, allocationSize = 1)
      public class AuditRevisionEntity implements Serializable, BasicRevisionEntity {
          private static final long serialVersionUID = 1L;
          private Long id;
          private long timestamp;
          private String userName;
          @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RevisionSequence")
          @Column(name = "id")
          public Long getId() {
              return this.id;


      This revisionn entity is used by all persistence units, e.g.:



      <persistence version="1.0"
          xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
          <persistence-unit name="PatientManagementChimerism">


      It works fine. I have a global revision entity and I can do nice horizontal audits from one schema to another. But I'm not sure if this is the right way to do it, since I didn't find any envers tutorial that explains how to use global revisions on multiple schemas. Also, as you can see, the revision name contains the schema of the revision table (sequenceName = "space.seq_revision"). Hibernate seems to accept that even if this is not part of the JPA spec. My question is: Is this the right way to do it (are there alternatives)?