5

Hallo. I have the same issue explained here

The main difference is that I use EclipseLink as JpaProvider. So I configured my entityManagerFactory as below:

<bean id="entityManagerFactoryCont0" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation" value="classpath:META-INF/contratto-persistence-cont0.xml" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"/>
    </property>
    <property name="jpaDialect">
        <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
    </property>
</bean> 

I noticed that EclipseLink does not override the translateExceptionIfPossible method of DefaultJpaDialect class, and this is bad...

So in my test case I have a unique constraint violation exception and debugging the control flow shows this stacktrace:

EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(RuntimeException) line: 282   
EclipseLinkJpaDialect(DefaultJpaDialect).translateExceptionIfPossible(RuntimeException) line: 120   
LocalContainerEntityManagerFactoryBean(AbstractEntityManagerFactoryBean).translateExceptionIfPossible(RuntimeException) line: 368   
ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(RuntimeException) line: 58   
DataAccessUtils.translateIfNecessary(RuntimeException, PersistenceExceptionTranslator) line: 213    
PersistenceExceptionTranslationInterceptor.invoke(MethodInvocation) line: 163   
ReflectiveMethodInvocation.proceed() line: 172

The exception of the call is:

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (JSP_OWN.IDX_MC_CC_RAPPORTI_02) violated

The final exception that is returned is the general JpaSystemException:

org.springframework.orm.jpa.JpaSystemException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: violata restrizione di unicità (CONT_OWN.PK_CONT_EVENT_MESSAGE)

Any idea how to get the machine works for EclipseLink? Kind regards

Massimo

Community
  • 1
  • 1
Massimo Ugues
  • 4,373
  • 8
  • 43
  • 56
  • What is the problem?! It is converted to a `DataAccessException`, the `JpaSystemException` is a `DataAccessException`. What is it that doesn't work according to you? – M. Deinum Oct 14 '13 at 08:19

0 Answers0