Skip to content
Ameen Abozaid
Planned lessonJNR-031-L03

@Transactional and proxies

  • Lesson 3 of 8
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

understand how the annotation works and why it can silently fail.

Planned topics

  • Spring wraps your bean in a proxy: begin before the method, commit or rollback after.
  • Only calls that go through the proxy get a transaction.
  • Self-invocation (this.other() in the same class) bypasses the proxy, so the annotation on other() is ignored.
  • Private, package-private, or final-class problems: use public methods on a Spring-managed bean.
  • Fix self-invocation by moving the method to another bean.
Draft outline details

Demonstration

java
public void transfer(...) { debit(...); credit(...); }   // called from outside
@Transactional public void debit(...) { ... }            // IGNORED when called via this.debit()

Check your understanding

Why is @Transactional ignored on a method called with this.?

Show answer

The call skips the proxy.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.