title: Audit table using "Envers" in Spring Hibernate java project
body: <p>We need to audit the existing table using envers. we don't have hibernate.xml instead of we are using application-context.xml. And we are creating schema through "liquibase-changeset", then how do I create through annotations like @Entity and @Audited.</p>
  
  <p>How do I solve this issue?</p>
  
  <p>I have added hibernate configuration likes</p>
  
  <pre><code>&lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.event.post-insert"&gt;org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.event.post-update"&gt;org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.event.post-delete"&gt;org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.event.pre-collection-update"&gt;org.hibernate.envers.event.AuditEventListener&lt;/prop&gt;
                  &lt;!-- &lt;prop key="hibernate.ejb.event.pre-collection-remove"&gt;org.hibernate.envers.event.AuditEventListener&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.event.post-collection-recreate"&gt;org.hibernate.envers.event.AuditEventListener&lt;/prop&gt; --&gt;
                  &lt;prop key="org.hibernate.envers.revision_field_name"&gt;REV&lt;/prop&gt;
                  &lt;prop key="org.hibernate.envers.revision_type_field_name"&gt;REVTYPE&lt;/prop&gt;
                  &lt;prop key="org.hibernate.envers.auditTablePrefix"&gt;&lt;/prop&gt;
                  &lt;prop key="org.hibernate.envers.auditTableSuffix"&gt;_HISTORY&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
  </code></pre>
  
  <p>Added @Audited annotation in my domain class</p>
  
  <pre><code>@Entity
  @Audited
  @Table(name="user")
  public class User implements Serializable {
  </code></pre>
  
  <p>But this configuration deleted my existing tables</p>
  
  <p>e.g</p>
  
  <pre><code>Mydatabase
  -----------
  
  user
  product
  order_details
  user_role
  login
  </code></pre>
  
  <p>I have 5 tables in my database. After running my application it displays 3 tables. Instead of creating "audit" table, it deletes the existing table.</p>
  
  <pre><code> Mydatabase
    -----------
  
    user
    product
    order_details
  </code></pre>
  
  <p>How to create audit(_HISTORY) table without touching existing tables???</p>