Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370429 - Throws eclipselink-proprietry DatabaseException instead of JPA-compliant PersistenceException
Summary: Throws eclipselink-proprietry DatabaseException instead of JPA-compliant Pers...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Chris Delahunt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-02 08:05 EST by Markus KARG CLA
Modified: 2022-06-09 10:16 EDT (History)
1 user (show)

See Also:


Attachments
wraps RuntimeExceptions in PersistenceExceptions (31.66 KB, patch)
2013-03-06 10:44 EST, Chris Delahunt CLA
no flags Details | Diff
additional patch (1.69 KB, patch)
2013-03-08 10:23 EST, Tom Ware CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus KARG CLA 2012-02-02 08:05:23 EST
Build Identifier: 2.3.2

Just noticed that when I forgot to add a field to my database, EclipseLink throws some eclipselink-proprietry DatabaseException instead of a JPA-compliant PersistenceException. The problem is that a the application software is vendor-agnostic, so it dies not expect that it has to catch eclipse-link proprietary exceptions. It solely catches PersistenceException. As a result, the JVM stops as DatabaseException extends RuntimeException. This is nasty behaviour. Obviously the problem should be catchable, so EclipseLink should throw a JPA-compliant exception instead.

Reproducible: Always

Steps to Reproduce:
Write an application that does not know anything about EclipseLink but solely uses vanilla JPA. The application shall access a database in a try-catch(PersistenceException) block but not catch RuntimeException.

Remove a database field that the application tries to read or write.

Run the application.

The JVM will stop due to RuntimeException (i. e. DatabaseException).
Comment 1 Tom Ware CLA 2012-02-17 10:46:05 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Chris Delahunt CLA 2013-03-06 10:44:29 EST
Created attachment 227997 [details]
wraps RuntimeExceptions in PersistenceExceptions
Comment 3 Chris Delahunt CLA 2013-03-06 10:51:26 EST
This fix causes JPA query methods getResultList, getSingleResult, execute, executeUpdate and EclipseLink's getResultCollection to wrap RuntimeExceptions in PersistenceExceptions and mark the transaction for rollback.  It includes a few test changes where EclipseLInk native exceptions were expected to be thrown that now receive PersistenceException instances wrapping the underlying cause.

This fixes most instances I could find.  Please file new bugs if additional methods are found to be still throwing native EclipseLink exceptions incorrectly.


Checked into Main (2.5) via SHA-1: 72354843858c801bfa11aa5e5cfd0c191b0e8242
Comment 4 Tom Ware CLA 2013-03-08 10:23:56 EST
Created attachment 228143 [details]
additional patch
Comment 5 Tom Ware CLA 2013-06-25 09:12:14 EDT
Changes have been checked into 2.3.4 and 2.4.3 as well.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:10:36 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:16:26 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink