orm¿ò¼ÜÓÐÄļ¸ÖÖÓ³Éä
orm ¿ò¼Üͨ¹ýÓ³É乤¾ßÓëÊý¾Ý¿â±í¼ò»¯Êý¾Ý¿â½»»¥£¬Ö÷ÒªÓÐ 5 ÖÖÓ³ÉäÀàÐÍ£º±íÓ³É䣺ÿ¸öÀà¶ÔÓ¦Ò»¸ö±í£¬ÓŵãÊǽṹ¼òÆÓ£¬ÈõµãÊDZíÊýÄ¿¶à¿ÉÄܵ¼ÖÂÈßÓà¡£¼ÌÐøÓ³É䣺¼ÌÐøÀàÌõÀí½á¹¹Ó³Éäµ½Ò»¸ö±í£¬×èÖ¹ÈßÓ൫±í½á¹¹¿ÉÄÜÖØ´ó¡£»ìÌõÔ¼Ó³É䣺ÏêϸÀà¶ÔÓ¦±í£¬ÁýͳÀà²î³ØÓ¦£¬½á¹¹ÇåÎúµ«¿ÉÄÜÈßÓà¡£ÊôÐÔǶÈëÓ³É䣺ÊôÐÔÓ³Éäµ½ÁíÒ»¸öÀà±íÖУ¬×èÖ¹ÈßÓ൫±í½á¹¹¿ÉÄÜÖØ´ó¡£Öµ¹¤¾ßÓ³É䣺²»¿É±ä¹¤¾ßÓ³Éäµ½µ¥¸ö×ֶΣ¬¼ò»¯²Ù×÷µ«ÏÞÖƹ¤¾ßÖØ´óÐÔ¡£
ORM Ó³ÉäÀàÐÍ
ORM£¨¹¤¾ß¹ØϵӳÉ䣩¿ò¼Üͨ¹ý½«¹¤¾ßÓëÊý¾Ý¿â±í¾ÙÐÐÓ³É䣬¼ò»¯ÁËÓëÊý¾Ý¿âµÄ½»»¥¡£Æ¾Ö¤Ó³Éä·½·¨£¬ORM ¿ò¼ÜÖ÷ÒªÓÐÒÔϼ¸ÖÖÓ³ÉäÀàÐÍ£º
1. ±íÓ³É䣨Table per Class£©
- ÿ¸öÀàÓ³Éäµ½Ò»¸öµ¥¶ÀµÄ±í¡£
- ÀàµÄÊôÐÔÓ³Éäµ½±íµÄÁС£
- Óŵ㣺±í½á¹¹¼òÆÓ£¬Ò×ÓÚÃ÷È·¡£
- Èõµã£º±íÊýÄ¿¶à£¬¿ÉÄܻᵼÖÂÊý¾ÝÈßÓà¡£
2. ¼ÌÐøÓ³É䣨Table per Class Hierarchy£©
- ¼ÌÐøÀàÌõÀí½á¹¹Ó³Éäµ½Ò»¸ö±í¡£
- ¸¸ÀàµÄÊôÐÔÓ³Éäµ½±íµÄÁУ¬×ÓÀàµÄÊôÐÔÓ³Éäµ½ÌØÁíÍâÁС£
- Óŵ㣺×èÖ¹Á˱íÈßÓ࣬µ«¿ÉÄܵ¼Ö±í½á¹¹ÖØ´ó¡£
3. »ìÌõÔ¼Ó³É䣨Table per Concrete Class£©
- ÏêϸÀàÓ³Éäµ½Ò»¸öµ¥¶ÀµÄ±í£¬ÁýͳÀ಻ӳÉäµ½±í¡£
- Óŵ㣺±í½á¹¹ÇåÎú£¬µ«¿ÉÄܵ¼ÖÂÊý¾ÝÈßÓà¡£
4. ÊôÐÔǶÈëÓ³É䣨Embedded£©
- Ò»¸öÀàµÄÊôÐÔÓ³Éäµ½ÁíÒ»¸öÀàµÄ±íÖС£
- Óŵ㣺×èÖ¹Á˱íÈßÓ࣬µ«¿ÉÄܵ¼Ö±í½á¹¹ÖØ´ó¡£
5. Öµ¹¤¾ßÓ³É䣨Value Object£©
- Ò»¸ö²»¿É±äµÄ¹¤¾ßÓ³Éäµ½µ¥¸ö×ֶΡ£
- Óŵ㣺¼ò»¯Á˹¤¾ß²Ù×÷£¬µ«¿ÉÄÜ»áÏÞÖƹ¤¾ßµÄÖØ´óÐÔ¡£
³ýÁËÕâЩ»ù±¾µÄÓ³ÉäÀàÐÍÍ⣬ÓÐЩ ORM ¿ò¼Ü»¹Ö§³ÖÆäËû¸ß¼¶Ó³É书Ч£¬ÀýÈ磺
- ¹ØÁªÓ³É䣨Associations£©
- ¶à¶Ô¶àÓ³É䣨Many-to-Many£©
- ×Ô½ç˵ӳÉ䣨Custom Mapping£©
ÒÔÉϾÍÊÇorm¿ò¼ÜÓÐÄļ¸ÖÖÓ³ÉäµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡