Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Translating PersistenceException to DataAccessException with EclipseLinkJpaDialect
Translating PersistenceException to DataAccessException with EclipseLinkJpaDialect [message #683717] Tue, 14 June 2011 09:45 Go to next message
Massimo Ugues is currently offline Massimo UguesFriend
Messages: 10
Registered: January 2011
Junior Member
Hallo all.
I use EclipseLink as JPA vendor and I have a problem with the EclipseLinkJpaDialect.

I notice that extends DefaultJpaDialect but not overrides the translateExceptionIfPossible method.

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


Re: Translating PersistenceException to DataAccessException with EclipseLinkJpaDialect [message #692449 is a reply to message #683717] Mon, 04 July 2011 13:04 Go to previous message
jj Missing name is currently offline jj Missing nameFriend
Messages: 9
Registered: February 2011
Junior Member
Hi, I'm working on the same issue - I suspect its all working as designed, the code is using the EclipseLinkJpaDialect & is being processed by the translateExceptionIfPossible() method. The real problem is there is not a 'standard' persistence api subclass of PersistenceException that matches to the concept of a unique-constraint-exception. That being the case the translation falls through, skipping EntityExistsException, EntityNotFoundException etc.. to the generic PersistenceException.

The problem now seems how to move forward. Either start adding in custom mapping for the entity saves (where my exceptions are primarily generated) that pick up the constraint violation or apply a updated advice - I suppose it comes down to best practice. Any thoughts?
(no subject) [message #692452 is a reply to message #683717] Mon, 04 July 2011 13:04 Go to previous message
jj Missing name is currently offline jj Missing nameFriend
Messages: 9
Registered: February 2011
Junior Member
Hi, I'm working on the same issue - I suspect its all working as designed, the code is using the EclipseLinkJpaDialect & is being processed by the translateExceptionIfPossible() method. The real problem is there is not a 'standard' persistence api subclass of PersistenceException that matches to the concept of a unique-constraint-exception. That being the case the translation falls through, skipping EntityExistsException, EntityNotFoundException etc.. to the generic PersistenceException.

The problem now seems how to move forward. Either start adding in custom mapping for the entity saves (where my exceptions are primarily generated) that pick up the constraint violation or apply a updated advice - I suppose it comes down to best practice. Any thoughts?
Previous Topic:Problem having 2 different models
Next Topic:deploy .ear w/ JPA 2.0 provider=EclispeLink to WLS 10.3.1
Goto Forum:
  


Current Time: Fri Mar 29 11:46:51 GMT 2024

Powered by FUDForum. Page generated in 0.02598 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top