Native named query creation fails unintuitively when no resultClass is specified

Description

Given the following entity definition (see that the named query defines no resultClass):

And a request to create a named query specifying the result class:

Causes an ArrayIndexOutOfBoundsException at org.hibernate.internal.AbstractSharedSessionContract.resultClassChecking(AbstractSharedSessionContract.java:815)

"resultClassChecking" checks that there's only one result class defined, but doesn't account for the case when no result is defined.

As a user, I'd expect a simple error saying that the requested named query exists, but its result is not compatible.

I'm marking this issue as improvement as it is not a bug per se (expected behavior is to fail, just with a more clear message). Not sure if this is correct.

Environment

None

Assignee

Unassigned

Reporter

ggam

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure