NPE for Criteria query containing fetch join as a regression of HHH-12338

Description

I'm creating this new issue from an error report added recently to HHH-12338, which nobody seemed to notice.

The fix applied for causes a regression when @ElementCollection and @CollectionTable is used. The following mapping taken from an entity used to work until Hibernate 5.2.16. It causes a NPE for criteria queries starting from 5.2.17.

Until 5.2.16, the JPA meta model class generated for this entity contains a SetAttribute for readers:

Using 5.2.17, this becomes a SingularAttribute instead, which is obviously wrong (and it seems that @ElementCollection is not taken into account).

As a result, the following code then throws a NPE when creating a fetch join (last line). Debugging showed that Doc_.readers is null.

Environment

Observed with both Wildfly 10.1 and 12.

Status

Assignee

Chris Cranford

Reporter

Thorsten Möller

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.16

Components

Affects versions

Priority

Major
Configure