2 Replies Latest reply on Jul 23, 2009 4:46 AM by Adam Warski

    Inheritance.SINGLE TYPE Auditin not working

    Ganesh Sethuraman Newbie

      Adam,
      In @Inheritance(strategy = InheritanceType.SINGLE_TABLE).
      I annotated the subtypes with @Audited and not the parent class.Parent class is an abstract class.
      I got the following exception
      Caused by: 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 org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
      ... 39 more
      Caused by: java.lang.NullPointerException
      at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateInheritanceMappingData(AuditMetadataGenerator.java:305)
      at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:349)
      at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
      at org.hibernate.envers.configuration.AuditConfiguration.(AuditConfiguration.java:86)
      at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
      at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260)
      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)
      ... 43 more

      I annatated both Parent and Sub-Types with @Audited.
      then i got the following error

      Caused by: 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 org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
      ... 39 more
      Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
      at org.hibernate.envers.configuration.metadata.MetadataTools.addColumns(MetadataTools.java:154)
      at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateMappingData(AuditMetadataGenerator.java:263)
      at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:345)
      at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
      at org.hibernate.envers.configuration.AuditConfiguration.(AuditConfiguration.java:86)
      at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
      at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260)
      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)
      ... 43 more

      Adam what could be reason/resolution for the above error?
      I have added all the necessary listeners.

        • 1. Re: Inheritance.SINGLE TYPE Auditin not working
          Ganesh Sethuraman Newbie

          Adam,

          We did an analysis and found that it is due to Hibernate Descriminator Formula which we have used in our entity. Without this Hibernate Discriminator Formula it is working fine. please find below the error. Kindly help on this

          Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
          at org.hibernate.envers.configuration.metadata.MetadataTools.addColumns(MetadataTools.java:154)
          at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateMappingData(AuditMetadataGenerator.java:263)
          at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:345)
          at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
          at org.hibernate.envers.configuration.AuditConfiguration.(AuditConfiguration.java:86)
          at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
          at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260)
          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)

          • 2. Re: Inheritance.SINGLE TYPE Auditin not working
            Adam Warski Master

            Hello,

            well, looks like a bug :) Please create a jira bug.

            Adam