[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3945) Envers using inheritance gives NullPointer

robbie123456 (JIRA) noreply at atlassian.com
Thu Jun 4 11:17:13 EDT 2009


Envers using inheritance gives NullPointer
------------------------------------------

                 Key: HHH-3945
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3945
             Project: Hibernate Core
          Issue Type: Bug
          Components: envers
    Affects Versions: 3.5
         Environment: 3.2.6.ga
Oracle 10g
            Reporter: robbie123456


Using Envers version 3.5.0-SNAPSHOT:
class A extends from B. They both have @Entity and B has with @Inheritance(strategy=InheritanceType.JOINED), so fields in the subclass A have a separate table.

When only setting A to @Audited, I get following NullPointerException (found closed JIRA ticket: https://jira.jboss.org/jira/browse/ENVERS-71):
Caused by: java.lang.NullPointerException
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateInheritanceMappingData(AuditMetadataGenerator.java:253)
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:301)
    at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
    at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
    at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
    at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:259)
    at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:356)
    at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1304)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
    ... 39 more

NullPointerException happens here because 'entitiesConfigurations' is empty:
        String parentEntityName = pc.getSuperclass().getEntityName();
        ExtendedPropertyMapper parentPropertyMapper = entitiesConfigurations.get(parentEntityName).getPropertyMapper();


When also putting @Audited to the superclass B, I get following exception (also found on Hibernate JIRA ticket: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3647):

org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: B_AUD
    at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3635)
    at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347)
    at org.hibernate.id.Assigned.generate(Assigned.java:28)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
    at org.hibernate.envers.synchronization.work.ModWorkUnit.perform(ModWorkUnit.java:60)
    at org.hibernate.envers.synchronization.AuditSync.executeInSession(AuditSync.java:126)
    at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:150)
    at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:228)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:109)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at net.x.prl.services.common.audit.UserAuditInterceptor.invoke(UserAuditInterceptor.java:32)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at net.x.prl.services.common.ServiceExceptionInterceptor.invoke(ServiceExceptionInterceptor.java:34)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy114.updateQuantityOnSalesForecastLine(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy114.updateQuantityOnSalesForecastLine(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
    at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
    at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
    at net.x.buildit.middleware.jms.lingo.listener.EndpointExporterMessageListener.invokeAndCreateResult(EndpointExporterMessageListener.java:151)
    at net.x.buildit.middleware.jms.lingo.listener.EndpointExporterMessageListener.doInvoke(EndpointExporterMessageListener.java:106)
    at org.logicblaze.lingo.jms.JmsServiceExporterMessageListener.onMessage(JmsServiceExporterMessageListener.java:102)
    at net.x.buildit.middleware.jms.lingo.listener.EndpointExporterMessageListener.onMessage(EndpointExporterMessageListener.java:220)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:531)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:466)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:868)
    at java.lang.Thread.run(Thread.java:595)


Using Envers with entity classes without inheriting from another entity, gives no problem.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list