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

    Error on Quickstart Envers 1.2.0

    janger

      Hi,
      on page http://www.jboss.org/envers/quickstart.html
      the property-values for the Listener are wrong.

      org.hibernate.envers.event.VersionsEventListener doestn exist.

      It should be:

      <property name="hibernate.ejb.event.post-insert" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.post-update" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.post-delete" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener" />
      

      regards Jan


        • 1. Re: Error on Quickstart Envers 1.2.0
          adamw

          Hello,

          thanks a lot! Fixed.

          --
          Adam

          • 2. Re: Error on Quickstart Envers 1.2.0
            janger

            No Problem Adam,

            I observe the envers-upgrowth for some time now and beside fixed some bugs in 1.1.0 on my own - but you already fixed them in the latest revision, so there was no need to write a patch. Even though I didnt get your code complete, I am impressed what your have done so far! :)

            ByTheWay: A nice feature would be a kind of TemporalEntityManager, were u can save an entity directly together with the revisionEntity.
            like:

            tempManager.merge(myFooEntity,new MyRevEntity(somePerson, someChangeReason));

            So u dont have to lookup anything in the RevisionListener and u can easy pass some revision-information from the front to the back.

            just an idea, maybe crap :)

            regards Jan

            • 3. Re: Error on Quickstart Envers 1.2.0
              adamw

              Hello,

              the idea might be quite good :). That's true that the current way of handling revision entities is not always very convenient.

              Maybe just this would be enough:

              auditReader.getCurrentRevisionEntity(boolean create)
              


              The method would return the current revision entity, letting you to fill any of the custom fields. The create parameter would specify if a revision entity should be created, even if no audited entities have been modified.

              What do you think?

              Adam

              • 4. Re: Error on Quickstart Envers 1.2.0


                How does this map in hibernate.cfg.xml?
                In 1.1, I was able to use the

                <event type="post-insert">
                 <listener class="org.jboss.envers.event.VersionsEventListener" />
                </event>
                

                but I can't seem to adapt it.

                Instead, I'm getting
                ...
                Caused by: java.lang.NullPointerException
                at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateInheritanceMappingData(AuditMetadataGenerator.java:285)



                Thanks,
                ~Ann

                • 5. Re: Error on Quickstart Envers 1.2.0
                  adamw

                  Hello,

                  you should just use:

                  <event type="post-insert">
                   <listener class="org.hibernate.envers.event.AuditEventListener" />
                  </event>
                  

                  for all the events.

                  The NPE looks like a bug. Can you post your entities and configuration? Or even better, create a testcase and attach it to a JIRA bug?

                  --
                  Thanks,
                  Adam

                  • 6. Re: Error on Quickstart Envers 1.2.0
                    janger

                    Hi Adam,
                    sry for the late reply...
                    Your idea to put the functionality into the AuditReader looks good. :) Do u plan to implement it?

                    regards,
                    Jan

                    • 7. Re: Error on Quickstart Envers 1.2.0
                      adamw

                      Hello,

                      I suppose yes :). Maybe you can create a feature request in JIRA?

                      Adam

                      • 8. Re: Error on Quickstart Envers 1.2.0
                        janger

                        Hi Adam,
                        here is the new JIRA entry:
                        http://opensource.atlassian.com/projects/hibernate/browse/HHH-3823

                        regards,
                        Jan

                        • 9. Re: Error on Quickstart Envers 1.2.0
                          adamw

                          Thanks :)