الاستعلامات المشتقة (Derived queries)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
write queries from method names, and know when to stop.
الموضوعات المخطط لها
- Spring parses names like
findByNameContainingIgnoreCaseinto 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.
تفاصيل المخطط المبدئي
عرض عملي
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.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.