| EclipseLinkException [message #515675] |
Fri, 19 February 2010 12:53  |
Martin Woolstenhulme Messages: 4 Registered: February 2010 |
Junior Member |
|
|
EclipseLinkException is the root RuntimeException in the package org.eclipse.persistence.exceptions. This is similar to the manner of PersistenceException in the package javax.persistence. My question is why doesn't EclipseLinkException actually extend javax.persistence.PersistenceException?
In my application I programmed to JPA as specified in Java EE, but when I use the JPA implementation I don't get exceptions that adhere to the specification, they only mimic it. In theory, my application could swap JPA implementations and still work if my application only exposed itself to the Java EE specification.
Specifically, I'm catching the PersistenceException in my source, but the library is throwing EclipseLinkException, so I don't catch it and miss the opportunity to rollback my transaction. The fix is to step up one level and just catch java.lang.RuntimeException, but that adds more generality when I'm only dealing with persistence issues. Otherwise I can catch EclipseLinkException directly and lose some portability. The question isn't critical, but I am curious if someone has perspective on how API implementations map to the API specification.
|
|
|
| Re: EclipseLinkException [message #515710 is a reply to message #515675] |
Fri, 19 February 2010 16:06   |
Chris Delahunt Messages: 878 Registered: July 2009 |
Senior Member |
|
|
Hello,
PersistenceException is thrown when using JPA, EclipseLinkExceptions are thrown when using EclipseLink api directly (ie session.executeQuery(query) etc). EclipseLinkException does not extend PersistenceException to avoid having a JPA dependency within the native EclipseLink api.
If your application is using JPA only, you should only be getting javax.persistence.PersistenceExceptions. Can you provide an example where you see an EclipseLinkException from JPA methods?
Best Regards,
Chris
[Updated on: Fri, 19 February 2010 16:08] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05275 seconds