-
Notifications
You must be signed in to change notification settings - Fork 38.4k
HibernateExceptionTranslator translating to InvalidDataAccessApiUsageException when using vanilla Hibernate [SPR-14681] #19245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented The translation of However, the general feature was intentional (see #19024): As of Hibernate 5.2, a Hibernate |
Koen Serneels commented Thanks Jürgen. So, to be sure, the fix will imply that both IllegalStateException and IllegalArgumentException are no longer translated? Note: for completeness, the javadoc does mention this: |
Juergen Hoeller commented Yes, that's what I'm trying to balance out for this modern-day "native" use of Hibernate: just translating plain |
Juergen Hoeller commented Are you actually relying on Hibernate-originating |
Koen Serneels commented The second: we are throwing |
Juergen Hoeller commented It would be great if you could give the latest |
Koen Serneels opened SPR-14681 and commented
The new org.springframework.orm.hibernate5.HibernateExceptionTranslator uses a fallthrough in the sense that it first tries to map the exception using vanilla Hibernate (SessionFactoryUtils). If no translation could be done it tries JPA via EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible().
The latter troubles us as it is translating IllegalStateException to InvalidDataAccessApiUsageException. I'm not really sure why IllegalStateException and IllegalArgumentException get this special treatment, but ok. So now we suddenly end up with translated exceptions that weren't translated before. Since these extra translations are in context of JPA (as it is called 'convertJpaAccessExceptionIfPossible') this also makes no sense as we are not using JPA but vanilla Hibernate.
So, what is the correct way to make sure that we only get Hibernate exceptions translated? Afaic the HibernateExceptionTranslator has no options to turn off JPA translation and the LocalSessionFactoryBean extends HibernateExceptionTranslator without the option to inject another implementation. Wouldn't it make more sense to have the HibernateExceptionTranslator JPA unaware and add another translator in case JPA is actually used?
Affects: 4.3.2
Reference URL: https://stackoverflow.com/questions/39393116/how-to-deactivate-spring-data-exception-translation
Issue Links:
Referenced from: commits 4b44553, 34ab818
The text was updated successfully, but these errors were encountered: