O'Reilly logo

Java Persistence with MyBatis 3 by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Bootstrapping MyBatis

The key component of MyBatis is SqlSessionFactory from which we get SqlSession and execute the mapped SQL statements. The SqlSessionFactory object can be created using XML-based configuration or Java API.

We will explore various MyBatis configuration elements, such as dataSource, environments, global settings, typeAliases, typeHandlers, and SQL mappers, and instantiate SqlSessionFactory.

In this chapter, we will cover:

  • Configuring MyBatis using XML
  • Configuring MyBatis using Java API
  • Customizing MyBatis logging

Configuring MyBatis using XML

The most commonly used approach for building SqlSessionFactory is XML-based configuration. The following mybatis-config.xml file shows how a typical MyBatis configuration file looks: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required