[hibernate-dev] @org.hibernate.annotations.Index and NullPointerException in IndexOrUniqueKeySecondPass
Vlad Mihalcea
mihalcea.vlad at gmail.com
Wed Jun 7 10:17:44 EDT 2017
Hi,
You should try it with JPA @Index as well, and try to replicate it with one
of our test cases:
http://in.relation.to/2016/01/14/hibernate-jpa-test-case-template/
If it replicates, you should open a Jira issue along with your PR.
Thanks,
Vlad
On Wed, Jun 7, 2017 at 11:33 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.AbstractAutowireCapableBeanFac
> tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.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.InterceptorAwareHibernatePersi
> stenceProvider.createContainerEntityManagerFactory(
> InterceptorAwareHibernatePersistenceProvider.java:51)
> at
> org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.
> createNativeEntityManagerFactory(LocalContainerEntityManagerFac
> toryBean.java:353)
> at
> org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.
> buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
> at
> org.springframework.orm.jpa.AbstractEntityManagerFactoryBe
> an.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.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
> _______________________________________________
> 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