title: Hibernate Envers - Audit Tables are not getting created
body: <p>I have below setting in hibernate properties file</p>
  
  <pre><code>hibernate.ddl-auto=update
  org.hibernate.envers.audit_table_suffix=_AUDITED
  </code></pre>
  
  <p>And in pom.xml</p>
  
  <pre><code>       &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-envers&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>I have annotated my entity class with @Audited. Hibernate version is 5.1.0.Final</p>
  
  <p>What I am I doing wrong? My Audited tables are not getting created. I get the below exception when envers tries to insert in Audit table.</p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute batch; SQL [insert into dbo.STPTradeTicket_AUDITED (REVTYPE, DownStreamTicketId, TicketId, REV) values (?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute batch
      at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:261)
      at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
      at com.barclays.ib.syndicate.booking.service.impl.TradeTicketService$$EnhancerBySpringCGLIB$$4a814103.open(&lt;generated&gt;)
      at com.barclays.ib.syndicate.booking.service.engine.TradeGenerator.run(TradeGenerator.java:118)
      at com.barclays.ib.syndicate.booking.service.engine.TradeEngineThreadPool$TradeEngineThreadPoolThread.run(TradeEngineThreadPool.java:71)
  Caused by: org.hibernate.exception.SQLGrammarException: could not execute batch
      at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
      at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:119)
      at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:97)
      at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:147)
      at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.getBatch(JdbcCoordinatorImpl.java:203)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2901)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3421)
      at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)
      at org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:156)
      at org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:46)
      at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:899)
      at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:481)
      at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2353)
      at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:485)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:147)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:231)
      at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:65)
      at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:61)
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
      ... 12 more
  Caused by: java.sql.BatchUpdateException: Invalid object name 'dbo.STPTradeTicket_AUDITED'.
  </code></pre>