Kev siv @PersistenceContext yog dab tsi?
Kev siv @PersistenceContext yog dab tsi?

Video: Kev siv @PersistenceContext yog dab tsi?

Video: Kev siv @PersistenceContext yog dab tsi?
Video: looj phaj kev siv 2024, Hlis ntuj nqeg
Anonim

Koj ua tau siv tus @ PersistenceContext annotation txhawm rau txhaj rau EntityManager hauv EJB 3.0 tus neeg siv khoom (xws li lub xeev lossis lub xeev tsis muaj kev sib tham taum, xov taum taum, lossis servlet). Koj ua tau siv @ PersistenceContext yam tsis tau qhia txog unitName attribute rau siv OC4J default persistence unit, raws li Piv txwv 29-12 qhia.

Ib yam li ntawd, tib neeg nug, 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.

Tsis tas li ntawd, EntityManager yog dab tsi? Tus neeg saib xyuas qhov chaw . Hauv JPA, lub EntityManager interface yog siv los tso cai rau cov ntawv thov los tswj thiab tshawb nrhiav cov koom haum hauv cov ntaub ntawv sib raug zoo. Cov EntityManager yog API uas tswj lub neej ntawm cov xwm txheej. Ib EntityManager object tswj ib pawg ntawm cov koom haum uas txhais los ntawm ib tug persistence unit.

Yog li ntawd, kev siv EntityManager hauv JPA yog dab tsi?

JPA EntityManager yog siv nkag mus rau ib qho database hauv ib qho tshwj xeeb daim ntawv thov . Nws yog siv tswj xyuas cov xwm txheej tsis tu ncua, nrhiav cov koom haum los ntawm lawv qhov tseem ceeb ntawm tus kheej, thiab nug txog txhua qhov chaw.

@PersistenceContext nyob rau lub caij nplooj ntoos hlav khau raj yog dab tsi?

@ PersistenceContext yog JPA tus qauv annotation uas ua rau koj tswj tau zoo dua qhov twg persistence ntsiab lus koj txhaj tshuaj. caij nplooj ntoos hlav - khau raj - persistence- ntsiab lus teb -annotation/46114447#46114447.