2024 Tus sau: Lynn Donovan | [email protected]. Kawg hloov kho: 2023-12-15 23:47
Nyob ntawd yog peb qub txeeg qub teg daim ntawv qhia cov tswv yim txhais nyob rau hauv lub hibernate : Table Per Hierarchy.
Ntawm no, muaj pes tsawg hom qub txeeg qub teg muaj nyob rau hauv hibernate?
3 yam
Ib sab saum toj, dab tsi yog qhov qub txeeg qub teg zoo hauv hibernate? Txhais cov cuab yeej cuab tam yuav siv tau rau ib qho chaw hauv chav kawm hierarchy. Nws tau teev nyob rau hauv chav kawm ntawv uas yog lub hauv paus ntawm chav kawm hierarchy. Yog tias Keeb kwm annotation tsis tau teev los yog tsis muaj qub txeeg qub teg hom tau teev tseg rau cov chav kawm hierarchy, SINGLE_TABLE mapping tswv yim yog siv.
Ntawm no, dab tsi yog qhov qub txeeg qub teg hauv hibernate?
Qhov chaw qub txeeg qub teg txhais tau hais tias peb tuaj yeem siv cov lus nug polymorphic rau retrieving tag nrho cov sub-chav kawm thaum nug rau cov chav kawm super. Txij li thaum Hibernate yog kev siv JPA, nws muaj tag nrho cov saum toj no thiab ob peb Hibernate -cov yam ntxwv tshwj xeeb ntsig txog qub txeeg qub teg.
Vim li cas peb thiaj li siv qhov qub txeeg qub teg hauv hibernate?
Txheej txheem cej luam. Hibernate yog ib tug ntshiab Java object-relational daim ntawv qhia thiab persistence moj khaum uas tso cai koj rau daim ntawv qhia Java cov khoom qub qub rau cov rooj sib tham database siv XML configuration files. Siv Hibernate tuaj yeem txuag tau ntau lub sijhawm txhim kho ntawm ib qhov project, txij li tag nrho JDBC txheej yog tswj hwm los ntawm lub moj khaum.
Pom zoo:
Muaj pes tsawg theem ntawm indirection nyob rau hauv pointers koj muaj peev xwm muaj nyob rau hauv ib qho kev tshaj tawm?
Koj puas tuaj yeem muaj nyob rau hauv ib qho kev tshaj tawm? cov lus teb yog "tsawg kawg 12." txhawb ntxiv. ntawm saj, tab sis muaj qhov txwv. Muaj ob theem ntawm kev taw qhia (tus taw tes rau tus taw tes rau ib yam dab tsi) yog qhov ntau
Dab tsi yog qhov sib txawv ntawm qhov qub txeeg qub teg vs classical qub txeeg qub teg?
Yog li ntawd, tus qauv yog ib tug generalization. Qhov sib txawv ntawm cov qub txeeg qub teg thiab cov qub txeeg qub teg yog qhov qub txeeg qub teg qub qub yog txwv rau cov chav kawm qub txeeg qub teg los ntawm lwm cov chav kawm thaum cov khoom qub txeeg qub teg txhawb nqa cloning ntawm txhua yam khoom siv cov khoom sib txuas
Vim li cas Ntau qhov qub txeeg qub teg tau txais kev txhawb nqa hauv C ++ tab sis tsis nyob hauv Java?
C ++, Common lisp thiab ob peb lwm yam lus txhawb ntau yam qub txeeg qub teg thaum java tsis txhawb nws. Java tsis tso cai rau ntau yam qub txeeg qub teg kom zam qhov tsis meej pem los ntawm nws. Ib qho piv txwv ntawm qhov teeb meem no yog qhov teeb meem pob zeb diamond uas tshwm sim hauv ntau yam qub txeeg qub teg
Ib tug tswv cuab tiv thaiv yuav ua li cas yog tias cov chav kawm tau txais qub txeeg qub teg hauv pej xeem hom?
1) nyob rau hauv kev tiv thaiv qub txeeg qub teg, cov pej xeem thiab cov tswv cuab tiv thaiv los ua cov tswv cuab tiv thaiv nyob rau hauv chav kawm derived. Nyob rau hauv tus kheej qub txeeg qub teg, txhua yam yog ntiag tug. Vim tias lawv yog ib feem ntawm cov chav kawm hauv paus, thiab koj xav tau cov chav kawm hauv paus uas yog ib feem ntawm koj cov chav kawm derived
Dab tsi yog qhov qub txeeg qub teg Dab tsi yog qhov sib txawv ntawm qhov qub txeeg qub teg piav nrog piv txwv?
Inheritance yog ib txoj hauv kev kom tau txais cov yam ntxwv thiab kev coj cwj pwm ntawm ib chav kawm los ntawm lwm chav kawm. Cov chav kawm uas cov tswv cuab tau txais qub txeeg qub teg yog hu ua chav kawm hauv paus, thiab chav kawm uas tau txais cov tswv cuab tam sim no hu ua chav derived. Inheritance siv IS-A kev sib raug zoo