2 Replies Latest reply on Feb 22, 2012 12:00 PM by Paul Taylor

    Maven configuration required for Envers to work

    Paul Taylor Newbie

      Try as I might I cannot get Hibernate Envers to create any Audit tables, I wonder if i missing anything from my maven configuration relating to transactions to get it to do what I want, this is what I have

       

         <dependency>

            <groupId>org.hibernate</groupId>

            <artifactId>hibernate-core</artifactId>

            <version>3.6.10.Final</version>

          </dependency>

          <dependency>

            <groupId>org.hibernate</groupId>

            <artifactId>hibernate-entitymanager</artifactId>

            <version>3.6.10.Final</version>

          </dependency>

          <dependency>

            <groupId>org.hibernate</groupId>

            <artifactId>hibernate-envers</artifactId>

            <version>3.6.10.Final</version>

          </dependency>

          <dependency>

            <groupId>org.hibernate</groupId>

            <artifactId>hibernate-c3p0</artifactId>

            <version>3.6.10.Final</version>

          </dependency>

        • 1. Re: Maven configuration required for Envers to work
          Paul Taylor Newbie

          Oh man I have tried just about everythiung I can think of and still no audit tables being created, can anyone confirm that Envers even works when not using JPA and persistence.xml

          • 2. Re: Maven configuration required for Envers to work
            Paul Taylor Newbie

            Well it ocurred to me that the documentation glossed over creating the schema and didnt provide an example. Also there was nothing special I was doing when I called new SchemaExport(config).create(true, true) and I couldnt see how adding the event listeners or annotations would effect this.

             

            Eventually I found the problem you have to add

             

            config.setProperty(Environment.HBM2DDL_AUTO, "create-drop");

             

            to the configuration.

             

            But this doesnt seem to be documented anywhere

             

            Also it seems it now recreates hibernate classes when it first gets a SessionFactory  I dont want it to recreate the hibernate tables everytime I stert my application, only when I call my recreatedb() method.