Compared to JDBC, MyBatis greatly simplifies your code and keeps it clean, easy to understand and maintain.

Directory Structure

It's important to understand the best practices surrounding directory structures.

SqlSessions

Through this SqlSessions interface you can execute commands, get mappers and manage transactions.

SqlSessionFactoryBuilder

SqlSessionFactoryBuilder has five methods that are used to create SqlSessionFactory instances.

SqlSessionFactory build(InputStream inputStream)
SqlSessionFactory build(InputStream inputStream, String environment)
SqlSessionFactory build(InputStream inputStream, Properties properties)
SqlSessionFactory build(InputStream inputStream, String env, Properties props)
SqlSessionFactory build(Configuration config)

SqlSessionFactory

SqlSessionFactory has six methods that are used to create SqlSession instances.

SqlSession openSession()
SqlSession openSession(boolean autoCommit)
SqlSession openSession(Connection connection)
SqlSession openSession(TransactionIsolationLevel level)
SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level)
SqlSession openSession(ExecutorType execType)
SqlSession openSession(ExecutorType execType, boolean autoCommit)
SqlSession openSession(ExecutorType execType, Connection connection)
Configuration getConfiguration();

SqlSession

The SqlSession instance is the most powerful class in MyBatis. It is where you'll find all of the methods to execute statements, commit or rollback transactions and acquire mapper instances.

相关文章:

  • 2021-07-12
  • 2021-07-04
  • 2021-09-23
  • 2021-12-05
  • 2021-12-07
  • 2021-09-05
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2022-01-23
  • 2022-02-19
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-05-24
  • 2021-05-25
相关资源
相似解决方案