Announcement Announcement Module
Collapse
No announcement yet.
JPA + transactions: exceptions not translated Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA + transactions: exceptions not translated

    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
Working...
X