Scott Marlow commented on an issue
Hibernate ORM / Bug HHH-8477
Use javax.persistence.Query#unwrap to implement addNamedQuery, rather than direct type checking
An app-server might wrap queries for various reasons. The initial report here actual came about because WildFly App Server does in fact wrap the {{javax.persistence.Query}} instances Hibernate produces in non-transactional cases.

Currently Hibernate does a direct type check to implement {{javax.persistence.EntityManagerFactory#addNamedQuery}}, checkin...