عرض عملي: إصلاح التحميل الكسول دون Open Session in View
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
keep lazy relations working with OSIV off; prepares JNR-032-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Set
spring.jpa.open-in-view=false; call an endpoint that returns an entity with lazy lines. - See
LazyInitializationExceptionin the response. - Planned mistake: change the relation to
EAGER; show the extra queries everywhere. - Revert; add an entity graph or a DTO projection in the service method.
- Return a response DTO built inside the transaction; the exception is gone and the query count is low.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.