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

Steve Ebersole steve at hibernate.org
Wed Jun 7 12:04:17 EDT 2017


IMO this is a bug.  Even if it is deprecated, the thing should still work
to the extent possible until removed.  If you have not already, please
create a bug report @ https://hibernate.atlassian.net

And since you already have a proposed fix, creating a GitHub Pull Request
from it would help get it integrated.  Tests always help too since that
allows us to ensure that the same problem does become regressed later.

On Wed, Jun 7, 2017 at 8:23 AM Laurent Almeras <laurent.almeras at smile.fr>
wrote:

> 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 <+33%204%2026%2068%2095%2003>
>
>
> 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
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev


More information about the hibernate-dev mailing list