提交 29a6d24d 编写于 作者: S Stephane Nicoll

Clarify the use of @Cacheable in PostConstruct code

Update documentation to explicitly mention that the cache interceptor
must be fully initialized to provide the expected behavior and therefore
initialization code should not rely on this feature, i;e. typically in
PostConstruct callback.

Since the Transactional infrastructure has the exact same infrastructure,
update that section of the doc as well.

Issue: SPR-12700
上级 982f9ce6
......@@ -23871,7 +23871,9 @@ transactional proxy, which would be decidedly __bad__.
In proxy mode (which is the default), only external method calls coming in through the
proxy are intercepted. This means that self-invocation, in effect, a method within the
target object calling another method of the target object, will not lead to an actual
transaction at runtime even if the invoked method is marked with `@Transactional`.
transaction at runtime even if the invoked method is marked with `@Transactional`. Also,
the proxy must be fully initialized to provide the expected behaviour so you should not
rely on this feature in your initialization code, i.e. `@PostConstruct`.
====
Consider the use of AspectJ mode (see mode attribute in table below) if you expect
......@@ -49741,7 +49743,9 @@ In proxy mode (which is the default), only external method calls coming in throu
proxy are intercepted. This means that self-invocation, in effect, a method within the
target object calling another method of the target object, will not lead to an actual
caching at runtime even if the invoked method is marked with `@Cacheable` - considering
using the aspectj mode in this case.
using the aspectj mode in this case. Also, the proxy must be fully initialized to provide
the expected behaviour so you should not rely on this feature in your initialization
code, i.e. `@PostConstruct`.
====
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册