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.