Java persistence using MyBatis by Vinod Kayartaya

Java persistence using MyBatis

13 lectures - 1 hr 4 mins

What's included?

Video Icon 14 videos File Icon 1 file


Course intro
2 mins
14.2 KB
Get.. Set.. Go!
Overview of Mybatis
4 mins
Eclipse project with required dependencies
7 mins
Starting the H2 database in server mode
11 mins
Entity classes using Lombok
7 mins
Configuring Mybatis to work with our database
3 mins
CustomerDao mapper interface
9 mins
DaoFactory for creating a CustomerDao instance
5 mins
Add new customer
8 mins
Retrieve a customer by id
2 mins
Update customer data
3 mins
Delete a customer record
5 mins
Get all customers
2 mins
Get customers by city
3 mins


  • Basic knowledge of Java programming language
  • Very basic knowledge of RDBMS and SQL commands would be helpful
  • If you know JDBC, you can really appreciate MyBatis, but it's absolutely not necessary
  • Any Laptop/PC which can run Java applications using Eclipse 

What will you learn in this course?

  • Understand MyBatis SQL Mapper
  • Configure MyBatis
  • SqlSesssionFactory and SqlSession
  • Mapping SQL INSERT/SELECT/UPDATE/DELETE statements to your interface methods
  • Manage persistence of RDBMS data in your Java application with out writing a single line of JDBC code

Who this course for?

  • A beginner to Java programming
  • Developer looking to execute SQL commands using MyBatis
  • Software developers who create DAO layer of an application


MyBatis is a Java persistence framework that couples objects with stored procedures or SQL statements using an XML descriptor or annotations. MyBatis is free software that is distributed under the Apache License 2.0. MyBatis is a fork of iBATIS 3.0 and is maintained by a team that includes the original creators of iBATIS. Unlike ORM frameworks, MyBatis does not map Java objects to database tables but Java methods to SQL statements.

MyBatis lets you use all your database functionality like stored procedures, views, queries of any complexity and vendor proprietary features. It is often a good choice for legacy or de-normalized databases or to obtain full control of SQL execution. It simplifies coding compared to JDBC. SQL statements are executed with a single line. MyBatis provides a mapping engine that maps SQL results to object trees in a declarative way.

SQL statements can be built dynamically by using a built-in language with XML-like syntax or with Apache Velocity using the Velocity integration plugin. MyBatis integrates with Spring Framework and Google Guice. This feature allows one to build business code free of dependencies. MyBatis supports declarative data caching. A statement can be marked as cacheable so any data retrieved from the database will be stored in a cache and future executions of that statement will retrieve the cached data instead hitting the database. MyBatis provides a default cache implementation based on a Java HashMap and default connectors for integrating with: OSCache, Ehcache, Hazelcast and Memcached. It provides an API to plug other cache implementations.

Hi. My name is Vinod

Hi, my name is Vinod, and I am a software trainer, consultant and freelance developer. I am the creator some of the highest rated courses on Udemy. In my professional career, I have trained hundreds of thousands of software engineers. Teaching is not only my profession, but also a passion. Creating online courses gives me the opportunity to reach and help students across the world.