Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

JPA + transactions: exceptions not translated

$
0
0
Hi,

I'm using Spring 3.2 for accessing data through JPA with EclipseLink 2.4 + MySQL.

I'm having problems with Spring's exception translation.
For some reason a MySQLIntegrityConstraintViolationException thrown by the JDBC driver doesn't get translated into Spring's DataAccessException hierarchy.
My data access class is annotated with @Repository and a PersistenceExceptionTranslationPostProcessor bean is also registered in the Spring context.

Any ideas why the exception doesn't get translated?

Here're the relevant extracts from my Spring config:

Code:

<context:component-scan base-package="..."/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
...
</bean>
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

Please find attached the exception trace extract.

marko
Attached Files

Viewing all articles
Browse latest Browse all 297

Trending Articles