Lub neej voj voog ntawm JPA qhov chaw yog dab tsi?
Lub neej voj voog ntawm JPA qhov chaw yog dab tsi?

Video: Lub neej voj voog ntawm JPA qhov chaw yog dab tsi?

Video: Lub neej voj voog ntawm JPA qhov chaw yog dab tsi?
Video: Lub Voj Voog Ntawm Kev Coj Dab Qhuas (Daim 296) 2024, Kaum ib hlis
Anonim

Cov lub neej voj voog ntawm qhov chaw Cov khoom muaj plaub lub xeev: Tshiab, Tswj, Tshem Tawm thiab Detached. Thaum ib qhov chaw khoom yog pib tsim nws lub xeev yog Tshiab. Hauv lub xeev no cov khoom tseem tsis tau koom nrog EntityManager. kev nyob ruaj khov.

Ntawm no, JPA qhov chaw yog dab tsi?

A JPA lub koom haum class is a POJO (Plain Old Java Object) class, i.e. ib tug dog dig Java chav kawm uas tau cim tseg (annotated) raws li muaj peev xwm sawv cev rau cov khoom hauv database. Conceptually qhov no zoo ib yam li serializable chav kawm, uas yog cim raws li muaj peev xwm yuav serialized.

Tsis tas li ntawd, dab tsi yog qhov chaw sib cais hauv JPA? Los yog cov lus zoo sib xws thaum peb siv qhov sib txawv JPA tus muab kev pabcuam tshaj li Hibernate EntityManager. A cais qhov chaw (a.k.a. ib cais tawm object) yog ib yam khoom uas muaj tib ID li ib qhov chaw nyob rau hauv lub khw persistence tab sis qhov ntawd tsis yog ib feem ntawm cov ntsiab lus persistence (lub Scope ntawm kev sib kho EntityManager).

Ua li no, Persistencecontext yog dab tsi?

A persistence ntsiab lus yog ib pawg ntawm cov koom haum xws li tias rau txhua tus neeg tsis tu ncua muaj ib qho chaw tshwj xeeb. Hauv ib persistence ntsiab lus , cov chaw tswj hwm. Lub EntityManager tswj lawv lub neej voj voog, thiab lawv tuaj yeem nkag mus rau cov chaw khaws ntaub ntawv. Lub koom haum detached tsis tuaj yeem thauj khoom ntxiv rau lub xeev tsis tu ncua.

Kev siv @entity yog dab tsi?

Cov koom haum sawv cev rau cov ntaub ntawv tsis tu ncua khaws cia rau hauv cov ntaub ntawv sib raug zoo tau siv lub thawv-tswj persistence. Lawv tsis tu ncua vim tias lawv cov ntaub ntawv khaws cia tsis tu ncua hauv qee hom kev khaws cia cov ntaub ntawv, xws li cov ntaub ntawv khaws cia: lawv muaj sia nyob ntawm server tsis ua haujlwm, tsis ua haujlwm, lossis kev ua haujlwm tsis ua haujlwm.

Pom zoo: