عرض عملي: ربط Order وOrderLine كتجميع (Aggregate)
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
map the order aggregate; prepares JNR-030-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Create
Order(id, customer, status, createdAt) andOrderLine(id, product, quantity, unitPrice). - Add
@ManyToOne(LAZY)fromOrdertoCustomerand fromOrderLinetoProduct. - Add
lineswithcascade = ALL, orphanRemoval = trueand theaddLine/removeLinehelpers. - Planned mistake: add a line to the list without setting
line.setOrder(this); show the null foreign key error and fix it with the helper. - Save an order and read the SQL log: one order insert, then one insert per line.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.