Skip to content

Commit 47fdac9

Browse files
committed
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
1 parent 7ffa845 commit 47fdac9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/asciidoc/index.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23871,7 +23871,9 @@ transactional proxy, which would be decidedly __bad__.
2387123871
In proxy mode (which is the default), only external method calls coming in through the
2387223872
proxy are intercepted. This means that self-invocation, in effect, a method within the
2387323873
target object calling another method of the target object, will not lead to an actual
23874-
transaction at runtime even if the invoked method is marked with `@Transactional`.
23874+
transaction at runtime even if the invoked method is marked with `@Transactional`. Also,
23875+
the proxy must be fully initialized to provide the expected behaviour so you should not
23876+
rely on this feature in your initialization code, i.e. `@PostConstruct`.
2387523877
====
2387623878

2387723879
Consider the use of AspectJ mode (see mode attribute in table below) if you expect
@@ -49737,7 +49739,9 @@ In proxy mode (which is the default), only external method calls coming in throu
4973749739
proxy are intercepted. This means that self-invocation, in effect, a method within the
4973849740
target object calling another method of the target object, will not lead to an actual
4973949741
caching at runtime even if the invoked method is marked with `@Cacheable` - considering
49740-
using the aspectj mode in this case.
49742+
using the aspectj mode in this case. Also, the proxy must be fully initialized to provide
49743+
the expected behaviour so you should not rely on this feature in your initialization
49744+
code, i.e. `@PostConstruct`.
4974149745
====
4974249746

4974349747

0 commit comments

Comments
 (0)