Hi,
I am using spring 2.5.2 LocalEntityManagerFactoryBean to load an EntityManagerFactory for which Hibernate 3.2.6 is the persistence provider.
I define a
Code:
<filter-def name="previousVersionDiffRows" condition="WM_DIFFVER = :workspaceSavepointCombo">
<filter-param name="workspaceSavepointCombo" type="string" />
</filter-def>
in global file and then reference it in class hbm files without the condition.
Code:
<hibernate-mapping package="com.archinsurance.rdm.entity.reference.impl">
<class name="ReferenceDomainInstanceImpl" table="REF_DOMAIN_VALUE">
<id name="id" column="DOMAIN_OBJECT_INSTANCE_ID">
<generator class="sequence">
<param name="sequence">SEQ_DOMAIN_OBJECT_INSTANCE_ID</param>
</generator>
</id>
<property name="codeValue" column="CODE_VALUE" />
<property name="displaySequence" column="DISPLAY_SEQ" />
<property name="shortDescription" column="SHORT_DESC" />
<property name="description" column="VALUE_DESC" />
<component name="validityPeriod" class="com.archinsurance.rdm.entity.reference.ValidityPeriod">
<property name="validFromDate" column="VALID_FROM_DT" />
<property name="validToDate" column="VALID_TO_DT" />
</component>
<many-to-one name="referenceDomain" class="ReferenceDomainImpl" column="DOMAIN_OBJECT_ID" not-null="true">
</many-to-one>
<set name="previousVersion" inverse="true">
<key column="DOMAIN_OBJECT_INSTANCE_ID" />
<one-to-many class="com.archinsurance.rdm.entity.reference.diff.impl.ReferenceDomainInstanceDiffImpl" />
<filter name="previousVersionDiffRows" />
</set>
</class>
</hibernate-mapping>
I get the following exception at startup:
Code:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [testApplicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
... 58 more
Caused by: javax.persistence.PersistenceException: java.lang.NullPointerException
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:91)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:281)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1333)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1299)
... 68 more
Caused by: java.lang.NullPointerException
at org.hibernate.cfg.HbmBinder.parseFilter(HbmBinder.java:2938)
at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:1469)
at org.hibernate.cfg.HbmBinder$CollectionType$2.create(HbmBinder.java:2764)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2057)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2038)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:359)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
at org.hibernate.cfg.Configuration.add(Configuration.java:675)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:483)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 74 more
I think this has something to do with improper hibernate configuration ordering. I ran in debug mode and I see that the global filter-def hasnt been processed yet when it tries to process the filter in the class hbm file.
Is there any known workaround for this ? PS: when i deploy the same persistence unit inside jboss 4.2.2 I don't get this exception...