Life cycle and scope of mybatis

Fairy-KunKun 2022-05-14 14:37:48 阅读数:951


Incorrect use mybatis, Can cause serious concurrency problems ( Thread unsafe ).

SqlSessionFactory Should be valid throughout the application , And just one

Best practices , use spring Dependency injection container implementation .

temporary : Implement... In static code blocks SqlSessionFactory The creation of --- For once , Will not recreate

      SqlSessionFactory Use static modification , Class properties , Exists in the method area

Yes SqlSessionFactory encapsulation