Dao chav kawm nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Dao chav kawm nyob rau lub caij nplooj ntoos hlav yog dab tsi?

Video: Dao chav kawm nyob rau lub caij nplooj ntoos hlav yog dab tsi?

Video: Dao chav kawm nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Video: 25 tháng 7, 2022 2024, Kaum ib hlis
Anonim

Nws yog tus qauv tsim nyob rau hauv uas cov ntaub ntawv nkag khoom ( DAO ) yog ib yam khoom uas muab qhov kev paub daws teeb meem rau qee yam ntawm cov ntaub ntawv lossis lwm yam kev ua haujlwm tsis tu ncua. Caij nplooj ntoos hlav Cov ntaub ntawv nkag mus rau hauv lub moj khaum yog muab los ua ke nrog cov txheej txheem sib txawv xws li JDBC, Hibernate, JPA, iBatis thiab lwm yam.

Ua li no, dab tsi yog chav dao?

Data Access Object Pattern los yog DAO qauv yog siv los cais cov ntaub ntawv qib qis nkag mus rau API lossis kev ua haujlwm los ntawm cov kev pabcuam kev lag luam siab. Qhov no chav kawm yog lub luag haujlwm kom tau txais cov ntaub ntawv los ntawm cov ntaub ntawv uas tuaj yeem yog database / xml lossis lwm yam kev khaws cia.

Kuj Paub, Dab tsi yog Dao chav kawm hauv Java? Nws yog ib yam khoom/interface, uas yog siv mus saib tau cov ntaub ntawv los ntawm database ntawm cov ntaub ntawv cia. Vim li cas peb siv DAO : nws abstracts qhov retrieval ntawm cov ntaub ntawv los ntawm ib cov ntaub ntawv kev pab xws li ib tug database. Lub tswv yim yog "sib cais cov ntaub ntawv kev pabcuam tus neeg siv khoom sib txuas los ntawm nws cov ntaub ntawv nkag mus."

Xav txog qhov no, Dao chav kawm yog dab tsi hauv lub caij nplooj ntoos hlav khau?

DAO stands rau data access object. Feem ntau, cov DAO hoob yog lub luag haujlwm rau ob lub tswv yim. Encapsulating cov ntsiab lus ntawm cov txheej txheem persistence thiab muab CRUD interface rau ib qho chaw.

DAO thiab DTO yog dab tsi thaum caij nplooj ntoos hlav?

DAO yog ib chav kawm uas feem ntau muaj cov haujlwm CRUD xws li txuag, hloov tshiab, rho tawm. DTO tsuas yog ib yam khoom uas tuav cov ntaub ntawv. Nws yog JavaBean nrog piv txwv hloov pauv thiab setter thiab getters. DTO yuav dhau los ua tus nqi kwv yees rau DAO txheej thiab DAO txheej yuav siv cov khoom no mus txuas ntxiv cov ntaub ntawv siv nws txoj kev ua haujlwm CRUD.

Pom zoo: