3 Replies Latest reply on Oct 11, 2012 2:11 PM by adamw

    EnversHibernateToolTask not generating audit tables

    gilberthuph

      I'm trying to generate my schema with the org.hibernate.tool.ant.EnversHibernateToolTask ant task; the schema is generated but missing the _aud tables for my @Audited classes.

       

      I'm using <jpaconfiguration persistenceunit="MyPU" /> with the following persistence.xml

       

      {code:xml}

          <persistence-unit name="MyPU">

              <provider>org.hibernate.ejb.HibernatePersistence</provider>

              <class>[ ... entities ... ]</class>

              <properties>

                  <property name="dialect" value="org.hibernate.dialect.PostgreSQL82Dialect"/>

                  <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>

                  <property name="hibernate.connection.url"

                            value="jdbc:postgresql://localhost/mtdb"/>

                  <property name="hibernate.connection.username" value="username"/>

                  <property name="hibernate.connection.password" value="xxxxxx"/>

                  <property name="hibernate.hbm2ddl.auto" value="validate"/>

                  <property name="hibernate.show_sql" value="true"/>

                  <property name="org.hibernate.envers.audit_table_suffix" value="_aud"/>

              </properties>

          </persistence-unit>  

      {code:xml}

       

      Any ideas why the audit tables are missing from the generated schema?

        • 2. Re: EnversHibernateToolTask not generating audit tables
          gilberthuph

          Yes I did, that is what I based my configuration on. I'm actually calling ant via Gradle:

           

          {code}

          task generateDdl << {

              ant {

                  taskdef(name: 'hibernatetool',

                          classname: 'org.hibernate.tool.ant.EnversHibernateToolTask',

                          classpath: configurations.generateDdl.asPath)

                  mkdir(dir: "$buildDir/generated")

                  hibernatetool(destdir: "$buildDir/generated") {

                      jpaconfiguration(persistenceunit: "MyPU")

                      hbm2ddl(

                              export: false,

                              outputfilename: 'schema.sql',

                              drop: false,

                              create: true,

                              delimiter: ";",

                              format: true)

                      classpath {

                          pathelement(path: sourceSets.main.output.asPath)

                          pathelement(path: sourceSets.test.output.asPath)

                      }

                  }

              }

          }

          {code}

          • 3. Re: EnversHibernateToolTask not generating audit tables
            adamw

            Hmm no idea ... can you debug to check if AuditConfiguration.getFor(...) is called?

             

            Adam