Posted in Java, Spring framework

Defining HibernateExceptionTranslator

I wanted to avoid defining any Spring bean XML configuration generally for my Spring apps. Firing up Jetty with Maven, you may sometimes encounter the following:

java.lang.IllegalStateException: No persistence exception translators found in bean factory. Cannot perform exception translation. at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.

When defining your beans using annotations in Spring, simply specify a method annotated with @Bean that returns an instance of HibernateExceptionTranslator. The method name can be arbitrary.

Author:

I love to learn. I am not so interested in buzzwords when it comes to gadgets. I would rather see how they work. Software is no different. Just trying to be better one byte at a time ^_^