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

واحد إلى واحد

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

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

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

في هذا الدرس

map a one-to-one link and know its trade-offs.

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

  • @OneToOne with a unique foreign key column on the owning side.
  • Typical example: Customer and CustomerProfile.
  • Inverse (mappedBy) one-to-one cannot be lazy easily, because Hibernate must check if the row exists.
  • @MapsId shares the primary key with the parent and avoids a separate key.
  • Often an @Embeddable or a plain column set is simpler.
تفاصيل المخطط المبدئي

عرض عملي

java
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "customer_id", unique = true)
private Customer customer;

اختبر فهمك

When might an embeddable be better than one-to-one?

أظهر الإجابة

When the data has no identity and lives in the same table.

التطبيق

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

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

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

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