Dab tsi yog kev sib koom ua ke hauv hibernate?
Dab tsi yog kev sib koom ua ke hauv hibernate?

Video: Dab tsi yog kev sib koom ua ke hauv hibernate?

Video: Dab tsi yog kev sib koom ua ke hauv hibernate?
Video: Qhia txog tug neeg caws2 yaum tes taw yuav ua li cas ? thiaj pab tau 2024, Kaum ib hlis
Anonim

Raws li peb paub tias hloov tshiab () thiab ua ke () txoj hauv kev hibernate yog siv los hloov cov khoom uas nyob rau hauv lub xeev detached rau hauv lub xeev persistence. Ua ke yuav tsum tau siv li ntawd. Nws merges cov kev hloov pauv ntawm cov khoom sib cais nrog ib qho khoom hauv kev sib kho, yog tias muaj.

Tom qab ntawd, qhov sib txawv ntawm Merge thiab saveOrUpdate hauv hibernate yog dab tsi?

Yog koj siv saveOrUpdate , cov khoom khaws tseg yuav tsum tau txuas rau kev sib kho. Hibernate saib xyuas MERGING cov ntaub ntawv kom tsim nyog hibernate ntu txuas khoom thiab txuag cov ntaub ntawv. Tsuas yog downside ntawm kev siv MERGE yog tias cov khoom dhau los tsis cuam tshuam cov ntaub ntawv hloov pauv.

Tom qab, lo lus nug yog, Evict nyob rau hauv hibernate yog dab tsi? ntiab tawm () Txhawm rau tshem tawm cov khoom los ntawm kev sib tham cache, hibernate muab ntiab tawm () txoj kev. Tom qab tshem tawm cov khoom los ntawm qhov kev sib kho, txhua qhov kev hloov pauv rau cov khoom yuav tsis raug txuas ntxiv. Cov khoom sib txuas kuj tseem yuav raug cais tawm yog tias lub koom haum tau teeb tsa nrog cascade = " ntiab tawm ".

Kuj paub yog, hibernate hloov tshiab ua haujlwm li cas?

hloov tshiab () hloov tshiab () txoj kev tshiab lub koom haum rau persistence siv tus identifier ntawm detached khoom los yog tshiab piv txwv ntawm qhov chaw tsim nrog uas twb muaj lawm identifier. Yog tias cov khoom twb nyob rau hauv kev sib kho nrog tib tus cim, ces nws cuam tshuam.

EntityManager merge ua dab tsi?

Cov EntityManager . ua ke () kev ua haujlwm yog siv los ua ua ke cov kev hloov pauv ua rau ib qho khoom sib cais rau hauv cov ntsiab lus tseem ceeb. sib koom ua ke tsis ncaj qha hloov cov khoom rau hauv cov ntaub ntawv, nws sib koom ua ke cov kev hloov pauv rau hauv cov ntsiab lus tseem ceeb (kev lag luam).

Pom zoo: