[
https://issues.apache.org/jira/browse/ARIES-1251?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14201908#comment-14201908
]
Tuomas Kiviaho commented on ARIES-1251:
---------------------------------------
Both EMHandler/QuiesceEMFHandler at least do throw the originating cause as
seen below but instead they throw the InvocationTargetException container Andy
described above. By adding {code} } catch (InvocationTargetException e) { throw
e.getCause(); } {code} to both cases solves this problem.
{code}
static class EMHandler implements InvocationHandler {
private EntityManager delegate;
private DestroyCallback destroyCallback;
public EMHandler(EntityManager delegate, DestroyCallback
destroyCallback) {
this.delegate = delegate;
this.destroyCallback = destroyCallback;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
Object res = null;
try {
res = method.invoke(delegate, args);
} catch (IllegalArgumentException e) {
new
PersistenceException(NLS.MESSAGES.getMessage("wrong.JPA.version", new Object[]{
method.getName(), delegate
}), e);
}
// This will only ever be called once, the second time there
// will be an IllegalStateException from the line above
if ("close".equals(method.getName())) {
destroyCallback.callback();
}
return res;
}
}
{code}
> Support jpa 2.0 and 2.1 with the same code base
> -----------------------------------------------
>
> Key: ARIES-1251
> URL: https://issues.apache.org/jira/browse/ARIES-1251
> Project: Aries
> Issue Type: Improvement
> Components: JPA
> Reporter: Christian Schneider
> Assignee: Christian Schneider
> Fix For: jpa-container-1.0.2, jpa-container-context-1.0.4
>
>
> We currently have two separate code bases for jpa 2.0 and 2.1 support. This
> is very difficult to manage when we do source code changes.
> So I will try to create one code that supports both jpa 2.0 and 2.1 by using
> Dynamic Proxies where we implement EntityManager or EntityManagerFactory.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)