Cov txheej txheem:

Lub caij nplooj ntoos hlav LocalSessionFactoryBean yog dab tsi?
Lub caij nplooj ntoos hlav LocalSessionFactoryBean yog dab tsi?

Video: Lub caij nplooj ntoos hlav LocalSessionFactoryBean yog dab tsi?

Video: Lub caij nplooj ntoos hlav LocalSessionFactoryBean yog dab tsi?
Video: Lub caij nplooj ntoos hlav, pajnyiag Lauj new release song 6/29/30 [ MV OFFICIAL] 2024, Tej zaum
Anonim

Caij nplooj ntoos hlav muab cov LocalSessionFactoryBean chav kawm ua lub Hoobkas rau SessionFactory khoom. Cov LocalSessionFactoryBean Cov khoom raug teeb tsa raws li taum hauv IoC thawv, nrog rau ib lub zos JDBC DataSource los yog sib koom DataSource los ntawm JNDI.

Tsis tas li ntawd, SessionFactory nyob rau lub caij nplooj ntoo hlav yog dab tsi?

SessionFactory yog ib qho interface. SessionFactory tuaj yeem tsim los ntawm kev muab cov khoom Configuration, uas yuav muaj tag nrho DB ntsig txog cov ntsiab lus rub tawm los ntawm hibernate. cfg ua. xml file los yog hibernate. Cov SessionFactory yog cov khoom siv xov zoo thiab siv los ntawm tag nrho cov xov ntawm ib daim ntawv thov.

Ib sab saum toj no, kev siv HibernateTransactionManager yog dab tsi? Cov daim ntawv thov uas siv ib zaug hibernate kev sib kho Hoobkas rau kev lag luam database, muaj kev xaiv zoo rau siv HibernateTransactionManager . HibernateTransactionManager tuaj yeem ua haujlwm nrog dawb JDBC ib yam nkaus. HibernateTransactionManager tso cai rau tej hloov tshiab thiab bulk ntxig thiab xyuas kom meej cov ntaub ntawv.

Hais txog qhov no, Spring ORM yog dab tsi?

Caij nplooj ntoos hlav ORM DAO Class @Component yog Caij nplooj ntoos hlav annotation uas qhia cov Caij nplooj ntoos hlav thawv uas peb tuaj yeem siv chav kawm no los ntawm Caij nplooj ntoos hlav IoC (Dependency Txhaj). Peb siv JPA @PersistenceContext annotation uas qhia tias muaj kev vam khom rau qhov EntityManager.

Yuav ua li cas koj configure hibernate nyob rau hauv caij nplooj ntoos hlav?

Cia peb pom dab tsi yog cov kauj ruam yooj yim rau hibernate thiab caij nplooj ntoos hlav kev koom ua ke:

  1. tsim cov lus hauv database Nws yog xaiv tau.
  2. tsim applicationContext. xml cov ntaub ntawv Nws muaj cov ntaub ntawv ntawm DataSource, SessionFactory thiab lwm yam.
  3. tsim tus neeg ua haujlwm.
  4. tsim cov neeg ua haujlwm.
  5. tsim EmployeeDao.
  6. tsim InsertTest.

Pom zoo: