Hibernate / MyBatis Interview questions
What is MyBatis-Spring?
MyBatis-Spring is the integration library that lets MyBatis participate cleanly in a Spring application — wiring MyBatis's SqlSessionFactory and mapper beans into the Spring container, and critically, letting MyBatis operations participate in Spring's own transaction management rather than managing transactions independently.
Without this integration, combining MyBatis and Spring would require manually managing SqlSession lifecycles and reconciling MyBatis's own transaction handling with Spring's, which is exactly the friction MyBatis-Spring exists to remove: it provides a SqlSessionTemplate (a thread-safe wrapper suitable for injection as a Spring bean, unlike a raw SqlSession) and automatic mapper scanning via @MapperScan or XML equivalent configuration.
MyBatis-Spring is the lower-level integration library that MyBatis-Spring-Boot-Starter builds on top of for auto-configuration; using MyBatis-Spring directly (without the Spring Boot starter) is still common in traditional, non-Spring-Boot Spring applications where explicit Java or XML configuration is preferred over Spring Boot's convention-based auto-configuration.
More Related questions...