9 Replies Latest reply on Mar 23, 2009 10:54 AM by adamw

    Will you support non annotation hibernate (.hbm) configs?

    mdiskin

      Is this planned only for annotation hibernate/JPA enivronments.

      I'd like to use the framework, but holding off for JPA2 to switch to annotations.

      Thanks
      Mark

        • 1. Re: Will you support non annotation hibernate (.hbm) configs
          adamw

          Well, Envers is part of Hibernate so Hibernate is required. It will work regardless if you use JPA, Annotations or just xml configuration files.

          --
          Adam

          • 2. Re: Will you support non annotation hibernate (.hbm) configs
            zualex

            So why I get:

            org.hibernate.HibernateException: could not init listeners
            at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
            at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
            at zTest.Entityz.TestPerson.setUp(TestPerson.java:46)
            at junit.framework.TestCase.runBare(TestCase.java:128)
            at junit.framework.TestResult$1.protect(TestResult.java:110)
            at junit.framework.TestResult.runProtected(TestResult.java:128)
            at junit.framework.TestResult.run(TestResult.java:113)
            at junit.framework.TestCase.run(TestCase.java:120)
            at junit.framework.TestSuite.runTest(TestSuite.java:228)
            at junit.framework.TestSuite.run(TestSuite.java:223)
            at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
            at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
            at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
            Caused by: java.lang.ClassCastException: org.hibernate.cfg.Configuration
            at org.hibernate.envers.configuration.AuditConfiguration.
            (AuditConfiguration.java:78)
            at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
            at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:232)
            at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
            at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
            at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
            ... 17 more

            • 3. Re: Will you support non annotation hibernate (.hbm) configs
              adamw

              Ah yes, you're right ... AnnotationConfiguration is required, but you can still feed it with .hbm.xml files. Just instantiate AnnotationConfiguration instead of Configuration. It's needed because it contains some reflection/annotation reading utilities that I use in Envers.

              --
              Adam

              • 4. Re: Will you support non annotation hibernate (.hbm) configs
                zualex

                Ok, it works.

                There's a way to specify in the .hbm.xml configuration file the classes to be audited?

                Without using the annotation @Audited?

                • 5. Re: Will you support non annotation hibernate (.hbm) configs
                  adamw

                  Hello,

                  no, @Audited is the only option, xml configuration is not supported.

                  --
                  Adam

                  • 6. Re: Will you support non annotation hibernate (.hbm) configs
                    kaizersh

                    Hi,

                    Is there any plan to add support for this? Also, is there any way to specify if an entity is to be audited at runtime?

                    Thanks.

                    Regards
                    Kaizer

                    • 7. Re: Will you support non annotation hibernate (.hbm) configs
                      adamw

                      Hello,

                      no, not really, annotation is the only option. Why would you want to specify that an entity is audited at runtime? I always thought that it's a rather static thing :) You have to create the database tables etc ... Anyway, changing the way the configuration determines which entities are audited is easy - see AuditConfiguration, the palce where the annotations are read.

                      Adam

                      • 8. Re: Will you support non annotation hibernate (.hbm) configs
                        kaizersh

                        Hi,

                        The reason I need a "runtime" configuration is because we are developing a Product and the implementation teams would decide which entities are to be audited for each client. In the current case, we would need to add/remove the annotation where needed and build all the jars again as against having an external configuration where only the configuration needs to be changed and deployed.

                        Thanks.

                        Regards
                        Kaizer

                        • 9. Re: Will you support non annotation hibernate (.hbm) configs
                          adamw

                          I see - looks like a good usecase :)

                          Do you have any ideas on how to implement such run-time configuration support? I thought about a property, where you would specify the entities that are audited, but that wouldn't allow you to specify it per-property. Maybe some descriptor object? But how would you set that :) Well, ideas welcome :)

                          Adam