انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-029-L02

الاستعلامات المشتقة (Derived queries)

  • الدرس 2 من 7
  • Junior
في هذا الدرس 4 موضوعات

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

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

في هذا الدرس

write queries from method names, and know when to stop.

الموضوعات المخطط لها

  • Spring parses names like findByNameContainingIgnoreCase into JPQL.
  • Keywords: And, Or, Between, LessThan, OrderBy, Containing, IsNull.
  • Great for one or two conditions.
  • When the name grows past about 3 conditions, it is hard to read: switch to @Query.
  • Typos in property names fail at startup, which is a useful early warning.
تفاصيل المخطط المبدئي

عرض عملي

java
List<Product> findByCategoryIdAndPriceAmountLessThanOrderByNameAsc(Long categoryId, BigDecimal max); // too long
Optional<Product> findBySku(String sku);                                                             // good

اختبر فهمك

When should you replace a derived query with @Query?

أظهر الإجابة

When the name becomes hard to read, around three or more conditions.

التطبيق

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

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

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

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