13 Replies Latest reply on Feb 27, 2012 4:52 PM by Adam Warski

    How do I configure envers in Configuration class

    Paul Taylor Newbie

      Trying to use Envers, trouble is the documentation shows you what to do if you are using hibernate.cfg.xml or persistence.xml but Im just using properties with the Configuration class, whilst this is analagous to hibernate.cfg.xml I cant work out how to setup the enver listeners

       

      I have two tests, one to create the database which does not create any _AUD tables currently even though the tables have @Audited annotation added, and my second test that trys to get a revision unsuprisingly fails with

       

      org.hibernate.exception.SQLGrammarException: Table/View 'COVERIMAGE_AUD' does not exist.

       

      This is my config class

       

      public static Configuration getInitializedConfiguration()

          {

              Configuration config = new Configuration();

              config.setProperty("hibernate.connection.driver_class","org.apache.derby.jdbc.EmbeddedDriver");

              config.setProperty("hibernate.connection.url","jdbc:derby:C:/User/MESH/Database/songlayer");

              config.setProperty("hibernate.dialect","org.hibernate.dialect.DerbyDialect");

        //config.setProperty("org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator","org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider");

              config.setProperty("hibernate.connection.username","jaikoz");

              config.setProperty("hibernate.c3p0.min_size","20");

              config.setProperty("hibernate.c3p0.max_size","100");

              config.setProperty("hibernate.c3p0.timeout","300");

              config.setProperty("hibernate.c3p0.max_statements","50");

              config.setProperty("hibernate.c3p0.idle_test_period","3000");

              config.setProperty("hibernate.show_sql","true");

              config.setProperty("hibernate.ejb.event.post-insert","org.hibernate.envers.event.AuditEventListener");

              config.setProperty("hibernate.ejb.event.post-update","org.hibernate.envers.event.AuditEventListener");

              config.setProperty("hibernate.ejb.event.post-delete","org.hibernate.envers.event.AuditEventListener");

              config.setProperty("hibernate.ejb.event.pre-collection-update","org.hibernate.envers.event.AuditEventListener");

              config.setProperty("hibernate.ejb.event.pre-collection-remove","org.hibernate.envers.event.AuditEventListener");

              config.setProperty("hibernate.ejb.event.post-collection-recreate","org.hibernate.envers.event.AuditEventListener");

              //config.setProperty("hibernate.format_sql","true");

              config.addAnnotatedClass(SongParent.class);

              config.addAnnotatedClass(Song.class);

              config.addAnnotatedClass(CoverImage.class);

              config.addAnnotatedClass(CoverArt.class);

              return config;

          }