开发者

CDI: Intercepted method nested call from non-intercepted method of the same bean - should be invoked?

If I have methods

public List<IrcEvent> getEventsByCriteria(IrcEventCriteria crit, boolean descending) {
    return getEventsByCriteria(crit, 0, Integer.MAX_VALUE, descending);
}

@JpaTransactional
public List<IrcEvent> getEventsByCriteria(IrcEventCriteria crit, int first, int count, boolean descending) {
     ...
}

then the first method must be also annotated @JpaTransactional right?

I just found out that when a bean calls its own intercepted method, then the interceptor is not triggered. I assume that's because it's not the proxy called, but the "real instance" itself, thus it does not go through the proxy.

Is this covered by the spec / docs? I didn't find it yet. I ask because I want to be sure that if I annot开发者_如何学运维ate all public methods, they will not start calling interceptors multiple times in the future.


I can't recall seeing it in the spec, but that's the way proxies work. But anyway this is related to transaction propagation - whether invoking a transactional method with an existing running transaction should start a new transaction or not.

Get Seam 3 persistence module (with transaction support)


The 2nd "internal" call is not via a contextual reference anymore, so it's not intercepted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜