@Transactional والوكلاء (Proxies)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
understand how the annotation works and why it can silently fail.
الموضوعات المخطط لها
- 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 onother()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.
تفاصيل المخطط المبدئي
عرض عملي
public void transfer(...) { debit(...); credit(...); } // called from outside
@Transactional public void debit(...) { ... } // IGNORED when called via this.debit()اختبر فهمك
Why is @Transactional ignored on a method called with this.?
أظهر الإجابة
The call skips the proxy.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.