انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-016-L06

عرض عملي: تعديلات متزامنة باستخدام @Version

  • الدرس 6 من 7
  • Mid-level
في هذا الدرس 3 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

show two admins editing the same product and returning 409.

تفاصيل المخطط المبدئي

خطوة بخطوة

  1. Add @Version to Product and include version in the response DTO.
  2. Two clients fetch product 1 (version 3).
  3. Client A updates the name with version 3 and succeeds (version 4).
  4. Planned mistake: the update DTO omits the version, so the entity is loaded fresh and the conflict is missed. Fix: require the version in the request and compare it.
  5. Client B updates with version 3: ObjectOptimisticLockingFailureException, mapped by @ControllerAdvice to 409 with the current version.
  6. Write an integration test for the two-client conflict.

Prepares MID-016-LAB1.

اختبر فهمك

What must the client send back to make optimistic locking work across requests?

أظهر الإجابة

The version it read.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.