We're updating the issue view to help you get more done. 

@org.hibernate.annotations.Index and NullPointerException in IndexOrUniqueKeySecondPass

Description

I encounter a NullPointerException in IndexOrUniqueKeySecondPass with
Hibernate 5.2.10.Final (stack attached).

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() );

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() );

Encountered stack trace attached to this ticket.
I'm working on a PR.

Environment

Linux / Unit tests

Status

Assignee

Andrea Boriero

Reporter

Laurent Almeras

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Worked in

5.1.2

Components

Affects versions

5.2.10

Priority

Major