| The JPA spec (or at least its javadoc) mandates that javax.persistence.TypedQuery#getSingleResult throws a javax.persistence.NonUniqueResultException when the query has more than one result. Since 5.2, we are supposed to follow the JPA spec by default, regardless of the booting method (JPA or native), unless hibernate.native_exception_handling_51_compliance is set to true. However, we currently behave like this:
- If we booted using JPA, getSingleResult() throws a javax.persistence.NonUniqueResultException
- If we booted using native APIs, getSingleResult() throws a org.hibernate.NonUniqueResultException
The second item seems wrong. Especially since it's not affected by setting hibernate.native_exception_handling_51_compliance to false or hibernate.jpa.compliance.query to true. I only witnessed this behavior in 5.4, but I believe it also affects 5.3 and 5.2. |