[hibernate-dev] @org.hibernate.annotations.Index and NullPointerException in IndexOrUniqueKeySecondPass

Laurent Almeras laurent.almeras at smile.fr
Wed Jun 7 04:33:49 EDT 2017


Hello,

I encounter a NullPointerException in IndexOrUniqueKeySecondPass with 
Hibernate 5.2.10.Final (stack at the end of mail).

It appears that problem seems to be linked to 
@org.hibernate.annotations.Index (deprecated annotation) used in an 
embeddable component, due to the following code that does not consider 
that Index can be declared in an embedded field 
(IndexOrUniqueKeySecondPass, l.75-76):

PersistentClass persistentClass = (PersistentClass) 
persistentClasses.get( column.getPropertyHolder().getEntityName() );
Property property = persistentClass.getProperty( column.getPropertyName() );

I don't know if you are willing to work on this issue as:

  * @org.hibernate.annotations.Index is deprecated for long
  * Using @Index on an embedded field can be considered as tricky

But this used to work in previous Hibernate version (last known working 
version: 5.1.2.Final)

On my side, replacing getPropertyHolder().getEntityName() by 
column.getPropertyHolder().getEntityOwnerClassName() fix my problem.

PersistentClass persistentClass = (PersistentClass) 
persistentClasses.get( 
column.getPropertyHolder().getEntityOwnerClassName() );
Property property = persistentClass.getProperty( column.getPropertyName() );

Please let me know if you want to work further on this problem so that I 
create an issue on Jira.

The encountered stack trace (spring controlled Entity manager):

Caused by: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'entityManagerFactory' defined in 
com.rhonealpestourisme.sitra.core.common.config.spring.SitraCoreCommonJpaConfig: 
Invocation of init method failed; nested exception is 
java.lang.NullPointerException
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
     at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
     at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
     at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
     at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
     at 
org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
     at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
     at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
     at 
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
     at 
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
     ... 54 more
Caused by: java.lang.NullPointerException
     at 
org.hibernate.cfg.IndexOrUniqueKeySecondPass.doSecondPass(IndexOrUniqueKeySecondPass.java:76)
     at 
org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621)
     at 
org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1589)
     at 
org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
     at 
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:858)
     at 
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885)
     at 
fr.openwide.core.jpa.hibernate.ejb.InterceptorAwareHibernatePersistenceProvider.createContainerEntityManagerFactory(InterceptorAwareHibernatePersistenceProvider.java:51)
     at 
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
     at 
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
     at 
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
     at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
     ... 65 more

-- 
Logo <http://www.smile.fr/>

151 boulevard Stalingrad
69100 Villeurbanne
Tel : 04 26 68 95 00
Fax : 04 26 68 95 01
www.smile.fr <http://www.smile.fr/> 	
*Laurent ALMERAS*
Architecte technique
Email : laurent.almeras at smile.fr <mailto:laurent.almeras at smile.fr>
Tel : +33 4 26 68 95 03


bandeaux_mail 
<http://information-systems.smile.eu/?utm_source=signature&utm_medium=email&utm_campaign=signature>

eco Pour la planète, n'imprimez ce mail que si c'est nécessaire


More information about the hibernate-dev mailing list